home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-09-05 | 187.9 KB | 6,083 lines | [TEXT/MPS ] |
- æKY CopyrightNotice
- æC -----
- Copyright Apple Computer, Inc. 1985-1991, All rights reserved.
- 411 - CommToolBoxHelp - MPW 3.2 Final Release.
- Authors: Gabriel Lopez
- Craig Hotchkiss
- James "im" Beninghaus
-
- æKY Help
- CommToolBoxHelp
-
- æKL AboutCommToolBoxHelp
- CommResources.h
- Connections.h
- CTBUtilities.h
- FileTransfers.h
- Terminals.h
-
- æKY AboutCommToolBoxHelp
- æC
- __________________________________________________________________
- Version 1.0 Beta -- ETO #6?
-
- Contains information from
- "Inside the Macintosh Communications Toolbox"
- (Addison-Wesley, 1991)
- __________________________________________________________________
-
-
- æKY Connection Manager
- æC -----
- CMAbort CMIOKill
- CMAccept CMListen
- CMActivate CMMenu
- CMAddSearch CMNew
- CMBreak CMOpen
- CMChoose CMRead
- CMClearSearch CMRemoveSearch
- CMClose CMReset
- CMDefault CMResume
- CMDispose CMSetConfig
- CMEnglishToIntl CMSetRefCon
- CMEvent CMSetupCleanup
- CMGetConfig CMSetupFilter
- CMGetConnEnvirons CMSetupItem
- CMGetCMVersion CMSetupPostFlight
- CMGetProcID CMSetupPreFlight
- CMGetRefCon CMSetupSetup
- CMGetToolName CMSetUserData
- CMGetUserData CMStatus
- CMGetVersion CMValidate
- CMIdle CMWrite
- CMIntlToEnglish InitCM
-
- ConnRecord
-
-
- æKY Connections
- æC -----
- CMAbort CMIOKill
- CMAccept CMListen
- CMActivate CMMenu
- CMAddSearch CMNew
- CMBreak CMOpen
- CMChoose CMRead
- CMClearSearch CMRemoveSearch
- CMClose CMReset
- CMDefault CMResume
- CMDispose CMSetConfig
- CMEnglishToIntl CMSetRefCon
- CMEvent CMSetupCleanup
- CMGetConfig CMSetupFilter
- CMGetConnEnvirons CMSetupItem
- CMGetCMVersion CMSetupPostFlight
- CMGetProcID CMSetupPreFlight
- CMGetRefCon CMSetupSetup
- CMGetToolName CMSetUserData
- CMGetUserData CMStatus
- CMGetVersion CMValidate
- CMIdle CMWrite
- CMIntlToEnglish InitCM
-
- ConnRecord
-
-
- æKY ConnMgr
- æC -----
- CMAbort CMIOKill
- CMAccept CMListen
- CMActivate CMMenu
- CMAddSearch CMNew
- CMBreak CMOpen
- CMChoose CMRead
- CMClearSearch CMRemoveSearch
- CMClose CMReset
- CMDefault CMResume
- CMDispose CMSetConfig
- CMEnglishToIntl CMSetRefCon
- CMEvent CMSetupCleanup
- CMGetConfig CMSetupFilter
- CMGetConnEnvirons CMSetupItem
- CMGetCMVersion CMSetupPostFlight
- CMGetProcID CMSetupPreFlight
- CMGetRefCon CMSetupSetup
- CMGetToolName CMSetUserData
- CMGetUserData CMStatus
- CMGetVersion CMValidate
- CMIdle CMWrite
- CMIntlToEnglish InitCM
-
- ConnRecord
-
- æKY ConnRecord
- æC -----
- ConnHandle = ^ConnPtr;
- ConnPtr = ^ConnRecord;
- ConnRecord = RECORD
- procID : INTEGER;
- flags : CMRecFlags;
- errCode : CMErr;
- refCon : LONGINT;
- userData : LONGINT;
- defProc : ProcPtr;
- config : Ptr;
- oldConfig : Ptr;
- asyncEOM : LONGINT;
- reserved1 : LONGINT;
- reserved2 : LONGINT;
- cmPrivate : Ptr;
- bufferArray : CMBuffers;
- bufSizes : CMBufferSizes;
- mluField : LONGINT;
- asyncCount : CMBufferSizes;
- END;
-
- procID
- procID is the connection tool ID. This value is dynamically assigned
- by the Connection Manager when your application calls CMGetProcID.
-
- flags
- flags is a bit field that indicates certain specifics about a
- connection when the connection record is first created. The bit masks
- for are as follows:
-
- TYPE
- CMRecFlags = LONGINT;
- CONST
- cmData = $00000001;
- cmCntl = $00000002;
- cmAttn = $00000004;
-
- cmDataClean = $00000100;
- cmCntlClean = $00000200;
- cmAttnClean = $00000400;
-
- cmNoMenus = $00010000;
- cmQuiet = $00020000;
-
- Your application can turn on the cmNoMenus or cmQuiet bits when it calls
- CMNew (discussed later in this chapter). The connection tool will set
- the rest of these bits.
- If the tool sets the cmData, cmCntl, or cmAttn bit, your application
- can use a data, control, or attention channel. If the tool sets the
- cmDataClean, cmCntlClean, or cmAttnClean bit, your application can use
- a reliable (error-free, in order delivery) data, control, or attention
- channel.
- The connection tool will not display any custom menus if your
- application sets the cmNoMenus bit. The connection tool will not display
- any status dialog boxes or error alerts if your application sets the
- cmQuiet bit. If your application turns the cmQuiet bit on, it is
- responsible for displaying status dialog boxes and error alerts that
- the tool would have displayed. Applications typically use these two
- bits to hide the connection tool from the user.
-
-
- errCode
- errCode contains the last error encountered by the Connection Manager.
- Valid error codes are as follows:
-
-
- TYPE
- CMErr = OSErr;
- CONST
- cmGenericError = -1;
- cmNoErr = 0;
- cmRejected = 1;
- cmFailed = 2;
- cmTimeOut = 3;
- cmNotOpen = 4;
- cmNotClosed = 5;
- cmNoRequestPending = 6;
- cmNotSupported = 7;
- cmNoTools = 8;
- cmUserCancel = 9;
-
-
- refCon
- refCon is a four-byte field that your application can use.
-
-
- userData
- userData is a four-byte field that your application can use.
-
-
- defProc
- defProc is a procedure pointer to the main code resource of the
- connection tool that will implement the connection protocol. The
- connection tool’s main code resource is of type 'cdef'.
-
-
- config
- config is a pointer to a data block that is private to the connection
- tool. It can contain information such as data transfer rate or parity
- for direct asynchronous connections, phone numbers for modem connections,
- or an address for an AppleTalk® network connection; the contents vary
- from tool to tool.
- Your application can store the contents of config to save the state
- of a connection in a document. The structure, size, and contents of the
- configuration record are set by the tool. Your application can determine
- the size of the configuration record by calling GetPtrSize, overwrite
- its contents using BlockMove, and validate the contents with CMValidate.
- Your application can use CMGetConfig and CMSetConfig to manipulate
- fields in this record. For details, see “Interfacing with a Scripting
- Language,” later in this chapter. Your application can save the state
- of the connection record by saving the string returned from CMGetConfig.
- Also, your application can restore the configuration of the connection
- record by passing a saved string to CMSetConfig.
- You can find more information about config from a connection tool
- perspective in Chapter 8.
-
-
- oldConfig
- oldConfig is a pointer to a data block that is private to the
- connection tool and contains the most recently saved version of config.
- Your application is responsible for setting oldConfig when the user
- saves a session document.
-
-
- reserved0, reserved1, and reserved2
- reserved0, reserved1, and reserved2 are fields that are reserved for
- the Connection Manager. Your application must not use these fields.
-
-
- cmPrivate
- cmPrivate is a pointer to a data block that is private to the
- connection tool. Your application must not use this field.
-
-
- bufferArray
- bufferArray is a set of pointers to buffers for the data, control,
- and attention channels. These are the buffers that are used to read data
- to or write data from the entity. These buffers are allocated by the
- connection tool and are the exclusive property of the connection tool;
- your application should not use these buffers. The data type for
- bufferArray is CMBuffers and is defined under the description of
- bufSizes.
-
-
- bufSizes
- bufSixes contains the actual sizes of the buffers and it, too, should
- not be manipulated directly by an application. The data type for bufSizes
- is CMBufferSizes, and is defined as follows:
-
- TYPE
- CMBufFields = (
- cmDataIn,
- cmDataOut,
- cmCntlIn,
- cmCntlOut,
- cmAttnIn,
- cmAttnOut,
- cmRsrvIn, {Reserved for Apple}
- cmRsrvOut); {Reserved for Apple}
-
-
- CMBuffers = ARRAY[CMBufFields] OF Ptr;
- CMBufferSizes = ARRAY[CMBufFields] OF LONGINT;
-
-
- mluField
- mluField is a pointer to a private data structure that the Connection
- Manager uses when searching the data stream.
-
-
- asyncCount
- asyncCount is used by completion routines to determine how many
- bytes were actually transmitted or received on a particular channel.
- Completion routines are discussed in more detail later in this chapter.
-
-
- æKY InitCM
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$101 (or #257)
- æDT InitCM: CMErr;
- æC -----
- Initializing the Connection Manager
-
- Function InitCM : CMErr;
-
- Description: InitCM initializes the Connection Manager. Your
- application should call this routine only once, after
- calling the standard Macintosh Toolbox initialization
- routines.
-
- Warning : Your application must initialize the
- Communications Resource Manager (by calling InitCRM) and
- then the Communications Toolbox Utilities (by calling
- InitCTBUtilities), whether or not it uses any of their
- calls, before it initializes the Connection Manager.
-
- InitCM returns an operating system error code if
- appropriate. Your application must check for the
- presence of the Communications Toolbox before calling
- this function. Sample code under “Determining Whether
- the Managers are Installed” in Appendix C shows you
- how your application can make this check.
-
- Result Codes: cmGenericError, cmNoErr, cmNoTools.
-
-
- æKY CMGetProcID
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$107 (or #263)
- æDT CMGetProcID(name: Str255): INTEGER;
- æC -----
- Getting current procID information
-
- Function CMGetProcID(name: Str255): INTEGER;
-
- Description: Your application should call CMGetProcID just before
- creating a new connection record, to find out the
- CMGetProcID of a tool.
-
- name specifies a connection tool. If a connection tool
- is available with the specified name, its procID is
- returned. If name references a nonexistent connection
- tool, CMGetProcID returns –1.
-
-
- æKY CMNew
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$108 (or #264)
- æDT CMNew(procID: INTEGER; flags: CMRecFlags; desiredSizes: CMBufferSizes; refCon: LONGINT; userData: LONGINT): ConnHandle;
- æC -----
- Creating a connection record
-
- Function CMNew(procID : INTEGER; flags : CMRecFlags;
- desiredSizes : CMBufferSizes; refCon : LONGINT;
- userData : LONGINT) : ConnHandle;
-
- Description: Before your application can open a connection, it must
- create a connection record so the Connection Manager
- knows what type of connection to establish. CMNew
- creates a new connection record; fills in the fields
- that it can, based upon the parameters that were passed
- to it; and returns a handle to the new record in
- ConnHandle. CMNew automatically makes two calls to
- CMDefault (which is described later in this chapter) to
- fill in config and oldConfig. The Connection Manager
- then loads the connection tool main code resource,
- moves it high in the current heap, and locks it. If an
- error occurs that prevents a new connection record from
- being created (for example, running out of memory),
- CMNew passes back NIL in ConnHandle.
-
- procID is dynamically assigned by the Connection Manager
- to tools at run time. Applications should not store
- procID values in settings files. Instead, they should
- store tool names, which can be converted to procID
- values with the CMGetProcID routine. Your application
- should use the ID that CMGetProcID returns for procID.
-
- flags is a bit field with the following masks:
-
- CONST
- cmData = $00000001;
- cmCntl = $00000002;
- cmAttn = $00000004;
-
- cmDataClean = $00000100;
- cmCntlClean = $00000200;
- cmAttnClean = $00000400;
-
- cmNoMenus = $00010000;
- cmQuiet = $00020000;
-
- flags represents a request from your application for
- a level of connection service. If your application sets
- cmNoMenus, the connection tool will not display any
- custom menus. If your application sets cmQuiet, the
- connection tool will not display any windows.
- Applications typically use these bits to hide the
- connection tool from the user.
- The connection tool sets the other bits, and returns
- in the flags field of the connection record the level of
- connection service that it grants your application. The
- flags field is discussed in “Connection Record Data
- Structure,” earlier in this chapter.
- Apple Computer, Inc. has reserved the bits of flags
- not shown in this manual. Do not use them, or your code
- may not work in the future.
-
- desiredSizes specifies buffer sizes that your
- application requests for its read, write, control read,
- control write, attention read, and attention write
- channels. Your application can specify the sizes that
- it wants when it calls CMNew, but the connection tool
- might not provide the requested sizes. To have the tool
- set the size of these buffers, your application should
- put zeros in the array. These buffers become the
- exclusive property of the connection tool and should not
- be manipulated by the application in any way. The actual
- buffer sizes are kept in the bufSizes field of the
- connection record.
-
- refCon and userData are fields that your application can
- use.
-
-
- æKY CMDefault
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$118 (or #280)
- æDT CMDefault(VAR theConfig: Ptr; procID: INTEGER; allocate: BOOLEAN);
- æC -----
- Initializing the configuration record
-
- Procedure CMDefault(VAR theConfig: Ptr; procID: INTEGER; allocate:
- BOOLEAN);
-
- Description: CMDefault fills the specified configuration record with
- the default configuration specified by the connection
- tool. CMNew calls this procedure automatically when it
- fills in the config and oldConfig fields in a new
- connection record.
-
- If allocate is TRUE, the tool allocates space for
- theConfig in the current heap zone.
-
-
- æKY CMValidate
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$117 (or #279)
- æDT CMValidate(hConn: ConnHandle): BOOLEAN;
- æC -----
- Validating the configuration record
-
- Function CMValidate(hConn: ConnHandle): BOOLEAN;
-
- Description: CMValidate performs an internal consistency check on the
- configuration and private data records of the connection
- record. CMNew and CMSetConfig call this routine after
- they have created a new connection record, to make sure
- that the record contains values identical to those
- specified by the connection tool.
-
- If the validation fails, the Connection Manager returns
- TRUE and the tool fills the configuration record with
- default values by calling CMDefault.
- Your application can call this routine after
- restoring a configuration, to verify that the connection
- record contains the correct information, in a manner
- similar to that shown next.
-
- BlockMove(saveConfig,hConn^^.config,
- GetPtrSize(hConn^^.config));
- IF CMValidate(hConn) THEN BEGIN
- { validate failed }
- END
- ELSE BEGIN
- { validate succeeded }
- END
-
-
- æKY CMChoose
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$124 (or #292)
- æDT CMChoose(VAR hConn: ConnHandle; where: Point; idleProc: ProcPtr): INTEGER;
- æC -----
- Configuring a connection tool
-
- Function CMChoose(VAR hConn:ConnHandle; where: Point; idleProc:
- ProcPtr):INTEGER;
-
- Description: An application can configure a connection tool in one of
- three ways. The easiest and most straightforward way is
- by calling the CMChoose routine. This routine presents
- the user with a dialog box.
- The second way an application can configure a
- connection tool is by presenting the user with a custom
- tool-settings dialog box. This method is much more
- difficult, and involves calling six routines. The
- routines are described in the next section,
- “Custom Configuration of a Connection Tool,” and “The
- Custom Tool-Settings Dialog Box” in Appendix C provides
- example code.
- The third way your application can configure a
- connection tool is by using the scripting language
- interface, described in “Interfacing With a Scripting
- Language,” later in this chapter. This method allows
- your application to bypass user interface elements.
-
- where is the point, specified in global coordinates,
- where the upper-left corner of the dialog box should
- appear. It is recommended that your application place
- the dialog box as close as possible to the upper-left
- corner of the screen, because the size of the dialog box
- varies from tool to tool.
-
- idleProc is a procedure with no parameters that the
- Connection Manager will automatically call every time
- CMChoose calls the setup dialog box filter procedure.
- Pass NIL if your application has no idleProc.
-
- CMChoose returns one of the following values:
-
- CONST
- chooseDisaster = -2;
- choose Failed = -1;
- chooseAborted = 0;
- chooseOKMinor = 1;
- chooseOKMajor = 2;
- chooseCancel = 3;
-
- chooseDisaster means that the CMChoose operation
- failed, destroyed the connection record, and returned
- NIL in the connection handle.
-
- chooseFailed means that the CMChoose operation
- failed and the connection record was not changed.
-
- chooseAborted means that the user started to change
- the connection while it was still open but did not
- commit the changes. When users try to change connection
- tools while the connection is still open, the Connection
- Manager prompts them with a dialog box that asks if they
- want to make the change. If the user clicks No in this
- dialog box, the CMChoose routine returns chooseAborted.
-
- chooseOKMinor means that the user clicked OK in the
- dialog box but did not change the connection tool being
- used.
-
- chooseOKMajor means that the user selected OK in the
- dialog box and also changed the connection tool being
- used. The Connection Manager then destroys the old
- connection handle by calling CMDispose. The connection
- is closed down, all pending read and write operations
- are terminated, and a new connection handle is returned
- in hConn.
-
- chooseCancel means that the user clicked Cancel in the
- dialog box.
-
-
- æKY CMSetupPreflight
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$123 (or #291)
- æDT CMSetupPreflight(procID: INTEGER; VAR magicCookie: LONGINT): Handle;
- æC -----
- Setting up the custom tool-settings dialog box
-
- Function CMSetupPreflight(procID: INTEGER; VAR magicCookie:
- LONGINT): Handle;
-
- Description: CMSetupPreflight returns a handle to a dialog item list
- that your application appends to the custom
- tool-settings dialog box. The handle comes from the
- connection tool. (The calling application uses
- AppendDITL, discussed in Chapter 7.) This handle is not
- a resource handle. Your application is responsible for
- disposing of the handle when done with it.
- The connection tool can use CMSetupPreflight to
- allocate a block of private storage, and to store the
- pointer to that block in magicCookie. The magicCookie
- value should be passed to the other routines that are
- used to set up the custom tool-settings dialog box.
-
- procID is the ID for the connection tool that is being
- configured. Your application should get this value by
- using the CMGetProcID routine, discussed earlier in
- this chapter.
-
- Note: The refcon of the custom tool-settings dialog
- box should point to a data structure (shown next) in
- which the first two bytes are the tool procID and the
- next four bytes are magicCookie. UserItem routines,for
- example, may require procID to obtain tool resources.
-
- TYPE
- chooseDLOGdata = RECORD
- procID : INTEGER
- magicCookie : LONGINT
- END;
-
-
- æKY CMSetupSetup
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$119 (or #281)
- æDT CMSetupSetup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Setting up custom tool-settings dialog box items
-
- Procedure CMSetupSetup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie:
- LONGINT);
-
- Description: CMSetupSetup tells the connection tool to set up
- controls (such as radio buttons or check boxes) in the
- dialog item list returned by CMSetupPreflight.
-
- procID is the ID for the connection tool that is being
- configured. Your application should use the same value
- for procIDas it passed to CMSetupPreflight.
-
- theConfig is a pointer to a configuration record for the
- tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box in which configuration is
- taking place.
-
- magicCookie is a pointer to private storage for the
- connection tool.
-
-
- æKY CMSetupFilter
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$122 (or #290)
- æDT CMSetupFilter(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theEvent: EventRecord; VAR theItem: INTEGER; VAR magicCookie: LONGINT): BOOLEAN;
- æC -----
- Filtering custom tool settings dialog box events
-
- Function CMSetupFilter(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR theEvent:
- EventRecord; VAR theItem: INTEGER; VAR magicCookie:
- LONGINT): BOOLEAN;
-
- Description: Your application calls CMSetupFilter as a filter
- procedure before it calls the standard modal dialog box
- filter procedure for the custom tool-settings dialog box.
- This routine allows connection tools to filter events in
- the custom tool-settings dialog box.
-
- procID is the ID for the connection tool that is being
- configured. Your application should use the same value
- for procID as it passed to CMSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theEvent is the event record for which filtering is to
- take place.
-
- theItem can return the item clicked in the dialog box.
-
- magicCookie is a pointer to private storage for the
- connection tool.
-
- If the event passed in was handled, CMSetupFilter
- returns TRUE. FALSE indicates that your application
- should perform standard dialog box filtering.
-
-
- æKY CMSetupItem
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11A (or #282)
- æDT CMSetupItem(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER; VAR magicCookie: LONGINT);
- æC -----
- Processing custom tool-settings dialog box events
-
- Procedure CMSetupItem(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER;
- VAR magicCookie: LONGINT);
-
- Description: CMSetupItem processes events for controls in the custom
- tool-settings dialog box.
-
- procID is the ID for the connection tool being
- configured. Your application should use the same value
- for procID as it passed to CMSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theItem is the item clicked in the dialog box. This
- value can be modified and sent back.
-
- magicCookie is a pointer to private storage for the
- connection tool.
-
-
- æKY CMSetupCleanup
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11B (or #283)
- æDT CMSetupCleanup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Performing clean-up operations
-
- Procedure CMSetupCleanup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
-
- Description: CMSetupCleanup disposes of any storage allocated in
- CMSetupPreflight and performs other clean-up operations.
- If your application needs to shorten a dialog box, it
- should do so after calling this routine.
-
- procID is the ID for the connection tool that is being
- configured. Your application should use the same value
- for procID as it passed to CMSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- magicCookie is a pointer to private storage for the
- connection tool.
-
-
- æKY CMSetupPostflight
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$12B (or #299)
- æDT CMSetupPostflight(procID: INTEGER);
- æC -----
- Closing the tool file
-
- Procedure CMSetupPostflight(procID:INTEGER);
-
- Description: CMSetupPostflight closes the tool file if it is not
- being used by any sessions.
-
- procID is the ID for the connection tool that is being
- configured. Your application should use the same value
- for procID as it passed to CMSetupPreflight.
-
-
- æKY CMGetConfig
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11C (or #284)
- æDT CMGetConfig(hConn: ConnHandle): Ptr;
- æC -----
- Getting the configuration string
-
- Function CMGetConfig(hConn: ConnHandle): Ptr;
-
- Description: CMGetConfig gets a configuration string from the
- connection tool.
-
- CMGetConfig returns a null-terminated, C-style string
- from the connection tool containing tokens that fully
- describe the configuration of the connection record. For
- an example, see the description of the next routine. If
- an error occurs, CMGetConfig returns NIL.
- It is the responsibility of your application to
- dispose of Ptr.
-
-
- æKY CMSetConfig
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11D (or #285)
- æDT CMSetConfig(hConn: ConnHandle; thePtr: Ptr): INTEGER;
- æC -----
- Setting the configuration with a string
-
- Function CMSetConfig(hConn: ConnHandle; thePtr: Ptr): INTEGER;
-
- Description: CMSetConfig passes a configuration string to the
- connection tool.
-
- CMSetConfig passes a null-terminated, C-style string
- (see the example string later in this section) to the
- connection tool for parsing. The string is pointed to by
- thePtr and must contain tokens that describe the
- configuration of the connection record. The string can
- be any length.
- CMSetConfig ignores items it does not recognize or
- find relevant; such an occurrence causes the connection
- tool to stop parsing the string and to return the
- character position where the error occurred. If the
- connection tool successfully parses the string, it
- returns cmNoErr. If the connection tool does not
- successfully parse the string, it returns one of the
- following values: a number less than –1 to indicate an
- OSErr,–1 to indicate an unknown error, or a positive
- number to indicate the character position where parsing
- was stopped.
- Individual connection tools are responsible for the
- parsing operation.
-
- Sample: A null-terminated, C-style configuration string
-
- Baud 9600 dataBits 8 Parity None StopBits 1 Port
- "Modem Port" Handshake None HoldConnection False
- RemindDisconnect False\0
-
-
- æKY CMOpen
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10B (or #267)
- æDT CMOpen(hConn: ConnHandle; async: BOOLEAN; completor: ProcPtr; timeout: LONGINT): CMErr;
- æC -----
- Opening a connection
-
- Function CMOpen(hConn: ConnHandle; async: BOOLEAN; completor:
- ProcPtr; timeout: LONGINT): CMErr;
-
- Description: CMOpen attempts to open a connection, based on
- information contained in a connection record.
-
- hConn points to the connection record for the new
- connection.
-
- async specifies whether the opening request is
- asynchronous. If your application makes an asynchronous
- request, CMOpen returns cmNoErr immediately.
-
- completor specifies the completion routine to be called
- upon completion of an asynchronous open request.
- Completion routines are discussed in greater detail
- later in this chapter, in the section “Completion
- Routines.”
-
- CMOpen specifies a time period, in ticks, within which
- must be timeout completed before the connection tool
- returns a cmTimeOut error. For no timeout, use –1. For a
- single attempt to open the connection, use 0. Some
- connection tools ignore this parameter.
-
- If no error occurs during the open attempt, CMOpen
- returns cmNoErr. CMOpen returns a negative number if an
- operating system error occurred, or a positive number if
- a Connection Manager error occurred.
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmTimeout,
- cmNotClosed, cmNotSupported, cmUserCancel.
-
-
- æKY CMClose
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10E (or #270)
- æDT CMClose(hConn: ConnHandle; async: BOOLEAN; completor: ProcPtr; timeout: LONGINT; now: BOOLEAN): CMErr;
- æC -----
- Closing a connection
-
- Function CMClose(hConn: ConnHandle; async: BOOLEAN; completor:
- ProcPtr; timeout: LONGINT; now: BOOLEAN): CMErr;
-
- Description: CMClose closes a connection that is already open or in
- the process of opening.
-
- async specifies whether or not the close request is
- asynchronous. If your application requests an
- asynchronous close, CMClose returns noErr immediately.
-
- completor specifies the completion routine to be called
- upon completion of an asynchronous close request.
- Completion routines are discussed in greater detail
- later in this chapter, in the section “Completion
- Routines.”
-
- timeout specifies a time period, in ticks, within which
- the close operation must be completed before the
- connection tool returns a cmTimeOut error. For no
- timeout, use –1. For a single attempt to close the
- connection, use 0. Some connection tools ignore this
- parameter.
-
- When now is TRUE, the connection tool closes the
- connection immediately. When now is FALSE, the
- connection tool waits until all pending input and output
- have finished before closing the connection.
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmTimeout,
- cmNotOpen, cmNotSupported, cmUserCancel.
-
-
- æKY CMAbort
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10F (or #271)
- æDT CMAbort(hConn: ConnHandle): CMErr;
- æC -----
- Aborting a connection
-
- Function CMAbort(hConn: ConnHandle): CMErr;
-
- Description: CMAbort tells the Connection Manager to stop trying to
- complete a pending asynchronous open request. Any open
- completion routines are executed. Your application can
- also call this routine to stop an outstanding CMListen.
-
- hConn specifies the connection this routine affects.
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmNotOpen,
- cmNoRequestPending, cmNotSupported.
-
-
- æKY CMDispose
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$109 (or #265)
- æDT CMDispose(hConn: ConnHandle);
- æC -----
- Disposing of a connection record
-
- Procedure CMDispose(hConn: ConnHandle);
-
- Description: CMDispose disposes of the connection record and all
- associated data structures. It is up to the connection
- tool to decide whether or not to wait for all pending
- read and write operations to complete before closing and
- disposing of the connection.
-
- hConn specifies the connection record disposed of by
- this routine.
-
-
- æKY CMIdle
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10A (or #266)
- æDT CMIdle(hConn: ConnHandle);
- æC -----
- Idle procedure
-
- Procedure CMIdle(hConn: ConnHandle);
-
- Description: Your application should call CMIdle at least once every
- time it goes through its main event loop, so that the
- connection tool can perform idle-loop tasks.
-
- hConn specifies the connection for which idle-loop tasks
- are to be performed.
-
-
- æKY CMListen
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10C (or #268)
- æDT CMListen(hConn: ConnHandle; async: BOOLEAN; completor: ProcPtr; timeout: LONGINT): CMErr;
- æC -----
- Listening for incomming connection requests
-
- Function CMListen(hConn: ConnHandle; async: BOOLEAN; completor:
- ProcPtr; timeout: LONGINT): CMErr;
-
- Description: CMListen “listens” for a connection request from another
- entity. Your application, after it calls CMListen,
- should call CMStatus (which is described later in this
- section) to see if a connection request has been
- received (by checking the cmStatusIncomingCallPresent
- bit).
-
- async specifies whether or not the opening request is
- asynchronous. If your application makes an asynchronous
- request, CMListen returns cmNoErr immediately. If your
- application makes a synchronous request, CMListen stays
- in a “listen loop” until it receives the connection
- request.
-
- completor specifies the completion routine that the
- Connection Manager calls after it is done listening for
- the connection request. Completion routines are called
- only after asynchronous calls to CMListen. “Completion
- Routines,” later in this chapter, discusses completion
- routines in more detail.
-
- timeout specifies a time period, in ticks, within which
- a connection request must be received before the
- connection tool returns a cmTimeOut error. For no
- timeout, use –1. For a single listen, use 0. Some
- connection tools ignore this parameter.
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmTimeout,
- cmNotClosed, cmNotSupported, cmUserCancel.
-
-
- æKY CMStatus
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æTN $A08B A0^.w=$110 (or #272)
- æDT CMStatus(hConn: ConnHandle; VAR sizes: CMBufferSizes; VAR flags: CMStatFlags): CMErr;
- æC -----
- Getting connection status information
-
- Function CMStatus(hConn: ConnHandle; VAR sizes: CMBufferSizes;
- VAR flags: CMStatFlags): CMErr;
-
- Description: CMStatus returns a variety of useful status information
- about a connection. Your application can call this
- routine at interrupt level.
-
- sizes is a variable of type CMBufferSizes that contains
- the number of characters to be read or written on the
- data, control, and attention channels. The indexes of
- the array are as follows:
-
- cmDataIn, cmDataOut, cmCntlIn, cmCntlOut, cmAttnIn,
- cmAttnOut, cmRsrvIn, cmRsrvOut.
-
- flags is a bit field with the following masks:
-
- CONST
- {tool is opening connection}
- cmStatusOpening = $00000001;
- {connection is open}
- cmStatusOpen = $00000002;
- {tool is closing connection}
- cmStatusClosing = $00000004;
- {data present on data channel}
- cmStatusDataAvail = $00000008;
- {data present on cntl channel}
- cmStatusCntlAvail = $00000010;
- {data present on attn channel}
- cmStatusAttnAvail = $00000020;
- {data read pending}
- cmStatusDRPend = $00000040;
- {data write pending}
- cmStatusDWPend = $00000080;
- {cntl read pending}
- cmStatusCRPend = $00000100;
- {cntl write pending}
- cmStatusCWPend = $00000200;
- {attn read pending}
- cmStatusARPend = $00000400;
- {attn write pending}
- cmStatusAWPend = $00000800;
- {tool is breaking the connection}
- cmStatusBreakPending = $00001000;
- {tool is “listening” for data}
- cmStatusListenPend = $00002000;
- {call waiting for tool to handle}
- cmStatusIncomingCallPresent = $00004000;
-
-
- TYPE
- CMStatFlags = LONGINT;
-
-
- Result Codes cmGenericError, cmNoErr, cmNotSupported.
-
-
- æKY CMAccept
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$10D (or #269)
- æDT CMAccept(hConn: ConnHandle; accept: BOOLEAN): CMErr;
- æC -----
- Accepting or rejecting a connection request
-
- Function CMAccept(hConn:ConnHandle; accept:BOOLEAN): CMErr;
-
- Description: CMAccept accepts or rejects an incoming connection
- request.
-
- Typically, an application will perform some actions
- after a CMListen, the results of which determine whether
- to accept the request. CMAccept cannot be called from
- interrupt level.
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed,
- cmNoRequestPending, cmNotSupported.
-
-
- æKY CMIOKill
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$129 (or #297)
- æDT CMIOKill(hConn: ConnHandle; which: INTEGER): CMErr;
- æC -----
- Stopping an asynchronous input/output request
-
- Function CMIOKill(hConn: ConnHandle; which: INTEGER): CMErr;
-
- Description: CMIOKill terminates any pending input/output (I/O)
- requests on the specified channel.
-
- which indicates the channel, and can take one of the
- following values:
-
- cmDataIn, cmDataOut, cmCntlIn, cmCntlOut, cmAttnIn,
- cmAttnOut.
-
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmNotOpen,
- cmNotSupported.
-
-
- æKY CMReset
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$116 (or #278)
- æDT CMReset(hConn: ConnHandle);
- æC -----
- Resetting the connection
-
- Procedure CMReset(hConn: ConnHandle);
-
- Description: CMReset causes the connection to be reset. The exact
- state to which the connection is reset depends upon the
- connection protocol being implemented. The connection
- tool clears all local read and write buffers.
-
- æKY CMBreak
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$125 (or #293)
- æDT CMBreak(hConn: ConnHandle; duration: LONGINT; async: BOOLEAN; completor: ProcPtr);
- æC -----
- Sending breaks
-
- Procedure CMBreak(hConn: ConnHandle; duration: LONGINT; async:
- BOOLEAN; completor: ProcPtr);
-
- Description: CMBreak effects a break operation upon the connection.
- The exact effect of this operation depends upon the tool
- in use.
-
- duration specifies in ticks the length of the break.
-
- completor specifies the completion routine to be called
- upon completion of the break. Completion routines are
- called only after asynchronous calls to CMBreak.
- “Completion Routines,” later in this chapter, discusses
- completion routines in more detail.
-
-
- æKY CMGetConnEnvirons
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$12C (or #300)
- æDT CMGetConnEnvirons(hConn: ConnHandle; VAR theEnvirons: ConnEnvironRec): CMErr;
- æC -----
- Getting the connection environment
-
- Function CMGetConnEnvirons (hConn : ConnHandle; VAR theEnvirons :
- ConnEnvironRec) : CMErr;
-
- Description: CMGetConnEnvirons provides a means for obtaining
- connection environment information.
-
- CMGetConnEnvirons returns the connection environment
- record in theEnvirons for the connection specified by
- ConnHandle. The connection tool is responsible for
- filling in each field of ConnEnvironRec with either a
- value (if it has a valid value to supply) or 0.
- The structure for version 0 of the connection
- environment record is as follows:
-
- TYPE
- ConnEnvironRecPtr = ^ConnEnvironRec;
- ConnEnvironRec = RECORD;
- version : INTEGER;
- {version of this data structure}
- baudRate : LONGINT;
- {data transfer rate}
- dataBits : INTEGER;
- {number of significant bits per byte}
- channels : CMChannel;
- {supported channels}
- swFlowControl : BOOLEAN;
- {if software flow control is in use}
- hwFlowControl : BOOLEAN;
- {if hardware flow control is in use}
- flags : CMFlags;
- END;
-
- The version field takes on the following value:
-
- CONST
- curConnEnvRecVers = 0;
-
- The flags field of the ConnEnvironRec is a bit field
- with the following value:
-
- TYPE
- CMFlags = INTEGER;
-
- CONST
- cmFlagsEOM = $0001;
-
- Other bits of flags are reserved by Apple Computer, Inc.
-
- channels is a bit field with the following values:
-
- TYPE
- CMChannel = INTEGER;
-
- CONST
- cmData = $00000001;
- cmCntl = $00000002;
- cmAttn = $00000004;
-
- cmDataClean = $00000100;
- cmCntlClean = $00000200;
- cmAttnClean = $00000400;
-
- Other bits of channels are reserved by Apple Computer,
- Inc.
-
-
- Result Codes cmGenericError, cmNoErr, cmNotSupported, envVersTooBig
-
-
- æKY CMRead
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æTN $A08B A0^.w=$111 (or #273)
- æDT CMRead(hConn: ConnHandle; theBuffer: Ptr; VAR toRead: LONGINT; theChannel: CMChannel; async: BOOLEAN; completor: ProcPtr; timeout: LONGINT; VAR flags: CMFlags): CMErr;
- æC -----
- Reading data
-
- Function CMRead(hConn: ConnHandle; theBuffer: Ptr; VAR toRead:
- LONGINT; theChannel: CMChannel; async: BOOLEAN;
- completor: ProcPtr; timeout: LONGINT; VAR flags:
- CMFlags): CMErr;
-
- Description: CMRead reads data into a block of memory. Your
- application cannot queue multiple read requests for the
- same channel on the same connection. However, your
- application can have both a pending read and a pending
- write on the same channel at the same time. Your
- application can call this routine at interrupt level.
-
- Note: Your application should not check for an open
- channel prior to reading data. The connection tool might
- be interpreting data locally and, therefore, not need an
- open connection.
-
- theBuffer specifies the buffer to which the connection
- tool should read data.
-
- toRead specifies the number of bytes to be read. If your
- application calls this routine synchronously, the
- connection tool returns the actual number of bytes it
- read in toRead. Your application can call CMStatus to
- see if an asynchronous read is pending. If your
- application calls this routine asynchronously, the
- asyncCount field of the connection record contains the
- actual number of bytes read when the connection tool
- calls the completion routine.
-
- theChannel specifies the channel on which reading takes
- place. Acceptable values are as follows:
-
- CONST
- cmData = $00000001;
- cmCntl = $00000002;
- cmAttn = $00000004;
-
- async specifies whether or not the request is
- asynchronous. If an asynchronous request is made,
- cmNoErr is returned immediately.
-
- completor specifies the completion routine to be called
- upon completion of an asynchronous read request.
- Completion routines are discussed in greater detail
- later in this chapter in the section “Completion
- Routines.”
-
- timeout specifies a time period, in ticks, within which
- the connection tool must complete the read operation. If
- it does not finish within the specified time, a timeout
- error occurs. For no timeout, use –1. If your
- application specifies 0, the connection tool reads as
- many bytes, up to toRead bytes, as it can in one read
- attempt. Some connection tools ignore this parameter.
-
- flags indicates whether your application received an
- end-of-message indicator. If your application calls this
- routine asynchronously, the connection tool returns the
- end of message indicator in the reserved0 field of the
- connection record when the completion routine is called.
-
- CONST
- cmFlagsEOM = $0001;
-
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmTimeout,
- cmNotOpen, cmNoRequestPending, cmNotSupported.
-
-
- æKY CMWrite
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æTN $A08B A0^.w=$112 (or #274)
- æDT CMWrite(hConn: ConnHandle; theBuffer: Ptr; VAR toWrite: LONGINT; theChannel: CMChannel; async: BOOLEAN; completor: ProcPtr; timeout: LONGINT; flags: CMFlags): CMErr;
- æC -----
- Writing data
-
- Function CMWrite(hConn: ConnHandle; theBuffer: Ptr; VAR toWrite:
- LONGINT; theChannel: CMChannel; async: BOOLEAN;
- completor: ProcPtr; timeout: LONGINT; flags: CMFlags):
- CMErr;
-
- Description: CMWrite writes data from a block of memory. Your
- application cannot queue multiple write requests for the
- same channel on the same connection. However, your
- application can have both a pending read and a pending
- write on the same channel at the same time. Your
- application can call this routine at interrupt level.
-
- Note: Your application should not check for an open
- channel prior to writing data. The connection tool might
- be interpreting data locally and,therefore, not need an
- open connection.
-
- theBuffer specifies the buffer from which the connection
- gets the data to write.
-
- toWrite specifies the number of bytes to be written. If
- your application calls this routine synchronously, the
- connection tool returns the actual number of bytes it
- wrote in toWrite. Your application can call CMStatus to
- see if an asynchronous write is pending. If your
- application calls this routine asynchronously, the
- asyncCount field of the connection record contains the
- actual number of bytes written when the completion
- routine is called.
-
- theChannel specifies the channel on which writing takes
- place. Acceptable values are as follows:
-
- CONST
- cmData = $00000001;
- cmCntl = $00000002;
- cmAttn = $00000004;
-
- async specifies whether or not the request is
- asynchronous. If your application makes an asynchronous
- request, CMWrite returns cmNoErr immediately.
-
- completor specifies the completion routine to be called
- upon completion of an asynchronous write request.
- Completion routines are discussed in greater detail
- later in this chapter in the section “Completion
- Routines.”
-
- timeout specifies a time period, in ticks, within which
- the connection tool must complete the write operation.
- If it does not finish within thespecified period, a
- timeout error occurs. For no timeout, use –1. If your
- application specifies 0, the connection tool writes as
- many bytes, up to toWrite bytes, as it can in one write
- attempt. Some connection tools ignore this parameter.
-
- flags indicates whether the connection tool should send
- an end-of-message indicator. An end-of-message indicator
- needs to be supported by the particular communications
- protocol being used; if an end-of-message indicator is
- not supported by the connection protocol, your
- application should ignore this field.
-
- CONST
- cmFlagsEOM = $0001;
-
-
- Result Codes cmGenericError, cmNoErr, cmRejected, cmFailed, cmTimeout,
- cmNotOpen, cmNoRequestPending, cmNotSupported.
-
-
- æKY CMAddSearch
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$126 (or #294)
- æDT CMAddSearch(hConn: ConnHandle; theString: Str255; flags: CMSearchFlags; callBack: ProcPtr): LONGINT;
- æC -----
- Adding a data stream search
-
- Function CMAddSearch(hConn: ConnHandle; theString: Str255; flags:
- CMSearchFlags; callBack: ProcPtr): LONGINT;
-
- Description: When an application is reading data with CMRead, you can
- have the data stream searched for one or more patterns
- of bytes. To perform the search, your application must
- pass information to the Connection Manager, such as the
- connection on which the data stream is coming in and the
- sequence of bytes for which to look. CMAddSearch tells
- the Connection Manager to perform the search, passing it
- search-specific information as well. Each time your
- application calls CMAddSearch, the Connection Manager
- searches for an additional sequence of bytes.
-
- The value CMAddSearch returns is a search reference
- number that is used by the CMRemoveSearch routine
- (described later in this section). If CMAddSearch
- returns –1, the connection tool did not successfully
- add the search. Your application uses the search
- reference number to distinguish among different searches
- that may be occurring simultaneously on the same
- connection.
-
- flags is a field that describes the search to be
- performed. The appropriate values are as follows:
-
- TYPE
- CMSearchFlags = INTEGER;
-
- CONST
- cmSearchSevenBit = $0001;
-
- If cmSearchSevenBit is on, the Connection Manager
- matches only the low 7 bits of a character; otherwise,
- it matches all 8 bits. The other bits of flags are
- reserved by Apple Computer, Inc.
-
- callBack is a pointer to a routine the Connection
- Manager will call during CMRead in the event that the
- connection tool finds a match. The calling conventions
- for the call-back procedure are given in the next
- section.
-
-
- æKY MySearchCallBack
- æDT MySearchCallBack(hConn: ConnHandle; matchPtr: Ptr; refNum: LONGINT);
- æC -----
- What to do when there's a match
-
- Procedure MySearchCallBack(hConn: ConnHandle; matchPtr: Ptr;
- refNum: LONGINT);
-
- Description: The Connection Manager will pass control to a search
- call-back procedure in the event that the connection
- tool finds a match in the incoming data stream. This
- routine may be called at interrupt level.
-
- matchPtr points to the last matched character in the
- read buffer.
-
- MySearchCallBack uses the search reference number
- CMAddSearch returns.
-
- Note: The Connection Manager calls MySearchCallBack
- when a read is completed, and therefore might be called
- at interrupt level. If your application makes
- asynchronous calls, MySearchCallBack has the same
- restrictions as the standard Device Manager completion
- routines.
-
-
- æKY CMRemoveSearch
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$127 (or #295)
- æDT CMRemoveSearch(hConn: ConnHandle; refNum: LONGINT);
- æC -----
- Stopping a data stream search
-
- Procedure CMRemoveSearch(hConn: ConnHandle; refNum: LONGINT);
-
- Description: CMRemoveSearch removes the search with the specified
- reference number for the specified connection record.
- This routine cannot be called at interrupt level (making
- it impossible for MySearchCallBack to call this routine).
-
- refnum is the search reference number returned by
- CMAddSearch.
-
-
- æKY CMClearSearch
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$128 (or #296)
- æDT CMClearSearch(hConn: ConnHandle);
- æC -----
- Clearing all data stream searches
-
- Procedure CMClearSearch(hConn: ConnHandle);
-
- Description: CMClearSearch removes all searches associated with the
- specified connection record.
-
- CMClearSearch cannot be called from interrupt level.
-
-
- æKY CMActivate
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$113 (or #275)
- æDT CMActivate(hConn: ConnHandle; activate: BOOLEAN);
- æC -----
- Activate events
-
- Procedure CMActivate(hConn: ConnHandle; activate: BOOLEAN);
-
- Description: CMActivate processes an activate or deactivate event
- (for instance, installing or removing a custom tool
- menu) for a window associated with the connection.
-
- If activate is TRUE, the connection tool processes the
- activate event. Otherwise, it processes a deactivate
- event.
-
-
- æKY CMResume
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$114 (or #276)
- æDT CMResume(hConn: ConnHandle; resume: BOOLEAN);
- æC -----
- Resume events
-
- Procedure CMResume(hConn: ConnHandle; resume: BOOLEAN);
-
- Description: CMResume processes a resume or suspend event for a
- window associated with the connection.
-
- If resume is TRUE, the connection tool processes a
- resume event. Otherwise, it processes a suspend event.
-
-
- æKY CMMenu
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$115 (or #277)
- æDT CMMenu(hConn: ConnHandle; menuID: INTEGER; item: INTEGER): BOOLEAN;
- æC -----
- Menu events
-
- Function CMMenu(hConn: ConnHandle; menuID: INTEGER; item:
- INTEGER): BOOLEAN;
-
- Description: Your application must call CMMenu when the user chooses
- an item from a menu that is installed by the connection
- tool.
-
- CMMenu returns FALSE if the connection tool did not
- handle the menu event.
-
- CMMenu returns TRUE if the connection tool did handle
- the menu event.
-
-
- æKY CMEvent
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$12A (or #298)
- æDT CMEvent(hConn: ConnHandle; theEvent: EventRecord);
- æC -----
- Other events
-
- Procedure CMEvent(hConn: ConnHandle; theEvent: EventRecord);
-
- Description: When your application receives an event, it should check
- whether the refcon of the window is a tool’s ConnHandle.
- Such an event occurs, for example, when the user clicks
- a button in a dialog box displayed by the connection
- tool. If it does belong to a connection tool’s window,
- your application can call CMEvent.
-
- A window (or dialog box) created by a connection tool
- has a connection record handle stored in the refCon
- field for windowRecord.
-
-
- æKY CMIntlToEnglish
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11E (or #286)
- æDT MyCompletion(hConn: ConnHandle);
- æC -----
- Translating into English
-
- Function CMIntlToEnglish(hConn: ConnHandle; inputPtr: Ptr;
- VAR outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: CMIntlToEnglish converts a configuration string, which
- is pointed to by inputPtr, to an American English
- configuration string pointed to by outputPtr.
-
- The function returns an operating system error code if
- any internal errors occur. The connection tool allocates
- space for outputPtr. Your application is responsible for
- disposing of the pointer with DisposPtr when done with
- it.
- language specifies the language from which the
- string is to be converted. Valid values for this field
- are shown in the description of the Script Manager in
- Inside Macintosh, Volume V. If the language specified
- is not supported, this routine returns cmNoErr, but
- outputPtr is NIL.
-
-
- æKY CMEnglishToIntl
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$11F (or #287)
- æDT CMEnglishToIntl(hConn: ConnHandle; inputPtr: Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
- æC -----
- Translating from English
-
- Function CMEnglishToIntl(hConn: ConnHandle; inputPtr: Ptr; VAR
- outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: CMEnglishToIntl converts an American English
- configuration string, which is pointed to by inputPtr,
- to a configuration string pointed to by outputPtr.
-
- The function returns an operating system error code if
- any internal errors occur.
- The connection tool allocates space for outputPtr;
- your application is responsible for disposing of the
- pointer with DisposPtr when done with it.
- language specifies the language to which the string
- is to be converted. Valid values for this field are
- shown in the description of the Script Manager in Inside
- Macintosh, Volume V. If the language specified is not
- supported, cmNoErr is still returned, but outputPtr is
- NIL.
-
-
- æKY CMGetToolName
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$106 (or #262)
- æDT CMGetToolName(procID: INTEGER; VAR name: Str255);
- æC -----
- Getting the name of a tool
-
- Procedure CMGetToolName(procID: INTEGER; VAR name: Str255);
-
- Description: CMGetToolName returns in name the name of the tool
- specified by procID.
-
- If procID references a connection tool that does not
- exist, the Connection Manager sets name to an empty
- string.
-
-
- æKY CMSetRefCon
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$102 (or #258)
- æDT CMSetRefCon(hConn: ConnHandle; refCon : LONGINT);
- æC -----
- Setting the connection record's reference constant
-
- Procedure CMSetRefCon(hConn: ConnHandle; refCon : LONGINT);
-
- Description: CMSetRefCon sets the connection record’s refCon field to
- the specified value. It is very important that your
- application use this routine to change the value of the
- reference constant, instead of changing it directly.
-
-
- æKY CMGetRefCon
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$103 (or #259)
- æDT CMGetRefCon(hConn: ConnHandle): LONGINT;
- æC -----
- Getting the connection record's reference constant
-
- Function CMGetRefCon(hConn: ConnHandle): LONGINT;
-
- Description: CMGetRefCon returns the connection record’s reference
- constant.
-
-
- æKY CMSetUserData
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$104 (or #260)
- æDT CMSetUserData(hConn: ConnHandle; userData: LONGINT);
- æC -----
- Setting the userData field
-
- Procedure CMSetUserData(hConn: ConnHandle; userData: LONGINT);
-
- Description: CMSetUserData sets the connection record’s userData
- field to the specified value. It is very important that
- your application use this routine to change the value of
- the userData field, instead of changing it directly.
-
-
- æKY CMGetUserData
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$105 (or #261)
- æDT CMGetUserData(hConn: ConnHandle): LONGINT;
- æC -----
- Getting the userData field
-
- Function CMGetUserData(hConn: ConnHandle): LONGINT;
-
- Description: CMGetUserData returns the connection record’s userData
- field.
-
-
- æKY CMGetVersion
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$120 (or #288)
- æDT CMGetVersion(hConn:ConnHandle): Handle;
- æC -----
- Getting 'vers' resource information
-
- Function CMGetVersion(hConn:ConnHandle): Handle;
-
- Description: CMGetVersion returns a handle to a relocatable block,
- which contains the information in the connection tool’s
- 'vers' resource with ID=1. Your application is
- responsible for disposing of the handle when done with
- it.
-
- Note: The handle returned is not a resource handle.
-
-
- æKY CMGetCMVersion
- æFa Connections.a
- æFc Connections.h
- æFp Connections.p
- æMM
- æTN $A08B A0^.w=$121 (or #289)
- æDT CMGetCMVersion: INTEGER;
- æC -----
- Getting the Conection Manager version number
-
- Function CMGetCMVersion: INTEGER;
-
- Description: CMGetCMVersion returns the version number of the
- Connection Manager.
-
- The version number of the Connection Manager described
- in this document is:
-
- CONST
- curCMVersion = 1;
-
-
- æKY MyCompletion
- æDT MyCompletion(hConn: ConnHandle);
- æC -----
- Writing a completion routine
-
- Procedure MyCompletion(hConn: ConnHandle);
-
- Description: Completion routines have the same restrictions as do
- standard Device Manager completion routines. For
- example, your routines should not allocate memory. See
- the Device Manager chapters in Inside Macintosh for more
- information.
-
- When the Connection Manager calls MyCompletion, the
- errCode field of the connection record contains the
- appropriate error code. The asyncCount field of the
- connection record contains the actual number of bytes
- read or written. Because the errCode field of the
- connection record is used by all of the Connection
- Manager routines, it contains the error code for the
- asynchronous operation only during execution of
- MyCompletion.
-
-
- æKY Terminal Manager
- æC -----
- InitTM TMIdle
- TMActivate TMIntlToEnglish
- TMAddSearch TMKey
- TMChoose TMMenu
- TMClear TMNew
- TMClearSearch TMPaint
- TMClick TMRemoveSearch
- TMCountTermKeys TMReset
- TMDefault TMResize
- TMDispose TMResume
- TMDoTermKey TMScroll
- TMEnglishToIntl TMSetConfig
- TMEvent TMSetRefCon
- TMGetConfig TMSetSelection
- TMGetCursor TMSetupCleanup
- TMGetIndTermKey TMSetupFilter
- TMGetLine TMSetupItem
- TMGetProcID TMSetupPostflight
- TMGetRefCon TMSetupPreFlight
- TMGetSelect TMSetupSetup
- TMGetTermEnvirons TMSetUserData
- TMGetTMVersion TMStream
- TMGetToolName TMUpdate
- TMGetUserData TMValidate
- TMGetVersion
-
- TermRecord
-
-
- æKY Terminals
- æC -----
- InitTM TMIdle
- TMActivate TMIntlToEnglish
- TMAddSearch TMKey
- TMChoose TMMenu
- TMClear TMNew
- TMClearSearch TMPaint
- TMClick TMRemoveSearch
- TMCountTermKeys TMReset
- TMDefault TMResize
- TMDispose TMResume
- TMDoTermKey TMScroll
- TMEnglishToIntl TMSetConfig
- TMEvent TMSetRefCon
- TMGetConfig TMSetSelection
- TMGetCursor TMSetupCleanup
- TMGetIndTermKey TMSetupFilter
- TMGetLine TMSetupItem
- TMGetProcID TMSetupPostflight
- TMGetRefCon TMSetupPreFlight
- TMGetSelect TMSetupSetup
- TMGetTermEnvirons TMSetUserData
- TMGetTMVersion TMStream
- TMGetToolName TMUpdate
- TMGetUserData TMValidate
- TMGetVersion
-
- TermRecord
-
-
- æKY TermMgr
- æC -----
- InitTM TMIdle
- TMActivate TMIntlToEnglish
- TMAddSearch TMKey
- TMChoose TMMenu
- TMClear TMNew
- TMClearSearch TMPaint
- TMClick TMRemoveSearch
- TMCountTermKeys TMReset
- TMDefault TMResize
- TMDispose TMResume
- TMDoTermKey TMScroll
- TMEnglishToIntl TMSetConfig
- TMEvent TMSetRefCon
- TMGetConfig TMSetSelection
- TMGetCursor TMSetupCleanup
- TMGetIndTermKey TMSetupFilter
- TMGetLine TMSetupItem
- TMGetProcID TMSetupPostflight
- TMGetRefCon TMSetupPreFlight
- TMGetSelect TMSetupSetup
- TMGetTermEnvirons TMSetUserData
- TMGetTMVersion TMStream
- TMGetToolName TMUpdate
- TMGetUserData TMValidate
- TMGetVersion
-
- TermRecord
-
- æKY TermRecord
- æC -----
- TermHandle = ^TermPtr;
- TermPtr = ^TermRecord;
- TermRecord = RECORD
- procID : INTEGER;
- flags : TMFlags;
- errCode : TMErr;
- refCon : LONGINT;
- userData : LONGINT;
- defProc : ProcPtr;
- config : Ptr;
- oldConfig : Ptr;
- environsProc : ProcPtr;
- reserved1 : LONGINT;
- reserved2 : LONGINT;
- tmPrivate : Ptr;
- sendProc : ProcPtr;
- breakProc : ProcPtr;
- cacheProc : ProcPtr;
- clikLoop : ProcPtr;
- owner : WindowPtr;
- termRect : Rect;
- viewRect : Rect;
- visRect : Rect;
- lastIdle : LONGINT;
- selection : TMSelection;
- selType : TMSelTypes;
- mluField : LONGINT;
- END;
-
- procID
- procID is the terminal tool ID. This value is dynamically assigned by
- the Terminal Manager when your application calls TMGetProcID.
-
-
- flags
- flags is a bit field with the following masks:
-
- CONST
- tmInvisible = $00000001;
- tmSaveBeforeClear = $00000002;
- tmNoMenus = $00000004;
- tmAutoScroll = $00000008;
-
- TYPE
- TMFlags : LONGINT;
-
- If your application sets tmInvisible, the Terminal
- Manager maintains a terminal emulation but does not
- display it. Your application can use the terminal
- emulation and cache region to create some other
- presentation service, instead of a terminal emulation.
- If your application sets tmSaveBeforeClear, the
- terminal tool will try to cache the entire terminal
- emulation region in response to any clear-screen
- operation. Clear-screen operations are generated from a
- user’s request, a clear-screen character sequence, or a
- terminal-reset character sequence.
- If your application sets tmNoMenus, the terminal
- tool will not put up any custom menus.
- If your application sets tmAutoScroll, the terminal
- tool will automatically scroll the terminal emulation
- window (if necessary) while the user is highlighting a
- selection.
-
-
- errCode
- The Terminal Manager does not use errCode; it is included in this
- version (version 1.0) of the terminal record for reasons of historical
- preservation. Your application must not use this field.
-
-
- refCon
- refCon is a LONGINT that your application can use.
-
-
- userData
- userData is a LONGINT that your application can use.
-
-
- defProc
- defProc is a pointer to the main code resource of the terminal tool
- that will implement the specifics of the terminal emulation. The
- terminal tool’s main code resource is of type 'tdef'.
-
-
- config
- config is a pointer to a data block that is private to the terminal
- tool.
- Your application can store the contents of config to save the state
- of a terminal in a document. The structure, size, and contents of the
- configuration record are set by the tool. Your application can determine
- the size of the configuration record by calling GetPtrSize, overwrite
- its contents using BlockMove, and validate the contents with TMValidate.
- Your application can use TMGetConfig and TMSetConfig to manipulate
- fields in this record. For details, read “Interfacing with a Scripting
- Language,” later in this chapter. Your application can save the state of
- the terminal record by saving the string TMGetConfig returns. Also, your
- application can restore the configuration of the terminal record by
- passing a saved string to TMSetConfig.
- You can find a description of config from a terminal tool perspective in
- Chapter 8.
-
-
- oldConfig
- oldConfig is a pointer to a data block that is private to the
- terminal tool and contains the most recently saved version of config.
- Your application is responsible for setting oldConfig when the user
- saves a session document.
-
-
- environsProc
- environsProc is a pointer to a routine in your application that the
- terminal tool can call to obtain a record describing the connection
- environment. A more detailed description of environsProc appears later
- in this chapter in “Routines That Must Be in Your Application.”
-
-
- reserved1 and reserved2
- reserved1 and reserved2 are reserved for the Terminal Manager. Your
- application must not use this field.
-
-
- tmPrivate
- tmPrivate is a pointer to a data block that is private to the
- terminal tool. Your application must not use this field.
-
-
- sendProc
- sendProc is a pointer to a routine your application calls when it
- needs to send data to another application. A more detailed description
- of sendProc appears later in this chapter in “Routines That Must Be in
- Your Application.”
-
-
- breakProc
- breakProc is a pointer to a routine in your application that performs
- a break operation. The effect the break has depends on the terminal
- emulation being used. A more detailed description of breakProc appears
- later in this chapter in “Routines That Must Be in Your Application.”
-
-
- cacheProc
- cacheProc is a pointer to a routine in your application that saves
- lines that scroll off the top of the terminal emulation region. The
- terminal tool also uses this routine to save the terminal screen before
- a clear-screen operation (if the TMSaveBeforeClear bit is set in the
- flags field of the terminal record). A more detailed description of
- cacheProc appears later in this chapter in “Routines That Must Be in
- Your Application.”
-
-
- clikLoop
- clikLoop is a pointer to a routine in your application that handles
- mouse clicks. The terminal tool calls the click loop repeatedly when the
- user is clicking or dragging an object. A more detailed description of
- this routine appears later in this chapter in “Routines That Must Be in
- Your Application.”
-
-
- owner
- owner is a pointer to the grafPort in which your application displays
- the terminal emulation.
-
-
- termRect
- termRect is the portRect of the current window, minus the scroll
- bars. This portRect represent the boundaries of the terminal emulation
- region. Figure 4-3 shows how termRects relates to the terminal emulation
- window.
-
- Note: Your application can display the terminal
- emulation region in an area that is smaller than
- termRect, but it must not display the combination of the
- cache region and terminal emulation region in an area
- larger than termRect.
-
-
- viewRect
- viewRect is a rectangle, measured in pixels, that represents the
- screen of an actual terminal. For some terminal types—for instance,
- Teletype or VT102™— has viewRect 24 lines and 80 columns. The dimensions
- of viewRect remain constant except when elements such as a tab ruler or
- status bar appear in the terminal emulation window, or when the size of
- the display font changes. The relationship of termRect to viewRect
- determines how much of viewRect is visible in the terminal emulation
- window.
-
-
- visRect
- visRect is a rectangle that represents the currently visible rows
- and columns in the terminal emulation region (for text terminals).
- Numbering of rows and columns begins with the number 1.
- visRect.top is the top visible line, and visRect.left is the
- leftmost visible column in the terminal emulation region. visRect.bottom
- is the bottom visible line, and visRect.right is the rightmost visible
- column in the terminal region. These values are used by the application
- to determine scroll-bar values.
-
-
- lastIdle
- lastIdle is the last time, in ticks, that the idle procedure was
- called for the specified terminal record.
-
-
- selection
- selection is a data structure that describes the extent of the
- current selection in the terminal emulation window. Since selection can
- describe either a rectangle or a region, it describes the selection in
- one of two kinds of data structures: a Rect or a RgnHandle. The format
- of the TMSelection data structure is as follows:
-
- TYPE
- TMSelection = RECORD
- CASE INTEGER OF
- 1: (
- selRect : Rect;
- );
- 2: (
- selRgnHandle : RgnHandle;
- filler : LONGINT;
- );
- END;
-
- selRect is of type Rect and describes the rectangle that has been
- selected. On a text terminal, it contains the row/column pairs, with
- counting beginning at 1. On a graphics terminal, it contains pixel
- coordinates, with (1,1) being the topLeft corner of the terminal region.
- On a graphics terminal, if the selection is a MacPaint-style lasso,
- selection is a selRgnHandle that represents the selection region.
-
-
- selType
- selType is a field that further describes a selection; it indicates
- the highlighting mode that is used to show the selection. Valid values
- are as follows:
-
- CONST
- selTextNormal = $0001;
- selTextBoxed = $0002;
- selGraphicsMarquee = $0004;
- selGraphicsLasso = $0008;
-
- TYPE
-
-
- TMSelTypes = INTEGER;
-
- selGraphicsMarquee is a standard rectangular MacPaint-style marquee.
- selGraphicsLasso is a standard MacPaint-style lasso. Your application
- uses these types of highlighting with graphics terminals.
-
-
- mluField
- mluField is a LONGINT that terminal tools use. Your application does
- not need to be concerned with this field.
-
-
- æKY InitTM
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$301 (or #769)
- æDT InitTM: TMErr;
- æC -----
- Initializing the Terminal Manager
-
- Function InitTM: TMErr;
-
- Description: InitTM initializes the Terminal Manager. Your
- application should call this routine after it calls the
- standard Macintosh Toolbox initialization routines.
-
- Warning Your application must initialize the
- Communications Resource Manager (by calling InitCRM)
- and then the Communications Toolbox Utilities
- (by calling InitCTBUtilities), whether or not it uses
- any of their calls, before it initializes the Terminal
- Manager.
-
- InitTM returns an operating system error code if
- appropriate. Your application must check for the
- presence of the Communications Toolbox before calling
- this function. Sample code under “Determining Whether
- the Managers are Installed” in Appendix C shows you how
- your application can make this check.
-
- Result Codes tmGenericError, tmNoErr, tmNoTools
-
-
- æKY TMGetProcID
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31F (or #799)
- æDT TMGetProcID(name: Str255): INTEGER;
- æC -----
- Getting current procID information
-
- Function TMGetProcID(name: Str255): INTEGER;
-
- Description: Your application should call TMGetProcID just before
- creating a new terminal record, to find out the procID
- of a tool.
-
- name specifies a terminal tool. If a terminal tool is
- available with the specified name, its procID is
- returned. If name references a nonexistent terminal
- tool, TMGetProcID returns –1.
-
-
- æKY TMNew
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$302 (or #770)
- æDT TMNew(termRect: Rect; viewRect: Rect; flags: TMFlags; procID: INTEGER; owner: WindowPtr; sendProc: ProcPtr; cacheProc: ProcPtr; breakProc: ProcPtr; clikLoop: ProcPtr; environsProc: ProcPtr; refCon: LONGINT; userData: LONGINT): TermHandle;
- æC -----
- Creating a terminal record
-
- Function TMNew(termRect: Rect; viewRect: Rect; flags: TMFlags;
- procID: INTEGER; owner: WindowPtr; sendProc: ProcPtr;
- cacheProc: ProcPtr; breakProc: ProcPtr; clikLoop:
- ProcPtr; environsProc: ProcPtr; refCon: LONGINT;
- userData: LONGINT): TermHandle;
-
- Description: Once the Terminal Manager has been initialized, your
- application needs to call TMNew to create a terminal
- record to describe the terminal emulation that is to
- take place. TMNew creates a new terminal record, fills
- in the fields it can, based on the parameters that were
- passed to it, and returns a handle to the new record in
- TermHandle. TMNew automatically makes two calls to
- TMDefault (which is described later in this chapter) to
- fill in config and oldConfig. The Terminal Manager then
- loads the terminal tool’s main definition procedure,
- moves it high in the current heap, and locks it. If an
- error occurs that prevents a new terminal record from
- being created (for example, running out of memory),
- TMNew passes back NIL in TermHandle.
- Your application must set the current port to the
- terminal window before it calls TMNew.
-
- termRect is a rectangle in local coordinates that
- represents the boundaries of the terminal emulation
- region. Your application initially sets this value by
- passing it as a parameter to TMNew. viewRect is a subset
- of termRect, which the terminal tool can actually write
- into. Your application initially sets this value by
- passing it as a parameter to TMNew, but the terminal
- tool may resize it.
-
- flags is a bit field with the following masks:
-
- CONST
- tmInvisible = $00000001;
- tmSaveBeforeClear = $00000002;
- tmNoMenus = $00000004;
- tmAutoScroll = $00000008;
-
- flags represents a request from your application for a level of
- service.
- Apple Computer, Inc. has reserved the bits of flags that are not
- shown in this document. Do not use them, or your code may not
- work in the future.
- If your application sets tmInvisible, the Terminal Manager
- maintains a terminal emulation but does not display it. Your
- application can use the terminal emulation and cache regions to
- create some other presentation service instead of a terminal
- emulation.
- If your application sets tmSaveBeforeClear, the terminal tool
- attempts to cache the entire terminal emulation region in response
- to any clear-screen operation. Clear-screen operations are generated
- from either a user’s request, a clear-screen character sequence, or
- a terminal-reset character sequence.
- If your application sets tmNoMenus, the terminal tool does not
- display any custom menus.
-
- If your application sets tmAutoScroll, the terminal tool
- automatically scrolls the terminal emulation window (if necessary)
- while the user highlights a selection.
-
- procID values are dynamically assigned by the Terminal Manager to
- tools at run time. Applications should not store procID values in
- “settings” files. Instead, they should store tool names, which can
- be converted to procID values with TMGetProcID. Use the ID that
- TMGetProcID returns for procID.
-
- owner is a pointer to the window in which your application is
- displaying the terminal emulation. If tmInvisible is FALSE, owner
- should be a grafPort that the terminal tool has control over.
-
- sendProc is a pointer to a routine the terminal tool calls when it
- needs to send data on a connection. A more detailed description of
- sendProc appears later in this chapter, in the section “Routines
- That Must Be in Your Application.”
-
- cacheProc is a pointer to a routine in your application that saves
- lines that scroll off the top of the terminal emulation region. This
- routine also saves the terminal screen before a clear-screen
- operation (if TMSaveBeforeClear is set). If your application does
- not have a cacheProc, specify NIL in this field. A more detailed
- description of cacheProc appears later in this chapter in the
- section “Routines That Must Be in Your Application.”
-
- breakProc is a pointer to a routine in your application that
- performs some sort of break operation. The effect the break has
- depends upon the terminal emulation tool that your application is
- using. A more detailed description of breakProc appears later in
- this chapter in the section “Routines That Must Be in Your
- Application.”
-
- clikLoop is a pointer to a routine in your application that is
- called when the mouse button is held down. The terminal tool calls
- the click loop repeatedly when users are clicking and dragging the
- mouse. A more detailed description of clikLoop appears later in this
- chapter, in the section “Routines That Must Be in Your Application.”
- Specify NIL in this field if your application has no clikLoop
- procedure.
-
- environsProc is a pointer to a routine that the terminal tool calls
- when it requires information about the connection. See “Connection
- Manager Routines” in Chapter 3 for information about the
- CMGetConnEnvirons routine.
-
- userData and refCon are fields your application can use.
-
-
- æKY TMDefault
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$315 (or #789)
- æDT TMDefault(VAR theConfig: Ptr; procID: INTEGER; allocate: BOOLEAN);
- æC -----
- Initializing the terminal record
-
- Procedure TMDefault(VAR theConfig: Ptr; procID: INTEGER; allocate:
- BOOLEAN);
-
- Description: TMDefault fills the configuration record pointed to by
- theConfig with the default configuration, which is
- specified by the terminal tool with the given procID.
- TMNew calls this procedure automatically when it fills
- in the config and oldConfig fields in a new terminal
- record.
-
- If allocate is TRUE, the tool allocates space for
- theConfig in the current heap zone.
-
-
- æKY TMValidate
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$314 (or #788)
- æDT TMValidate(hTerm: TermHandle): BOOLEAN;
- æC -----
- Validating the terminal record
-
- Function TMValidate(hTerm: TermHandle): BOOLEAN;
-
- Description: TMValidate performs an internal consistency check on the
- configuration and private data records of the terminal
- record. TMNew and TMSetConfig call this routine after
- they have created a new terminal record, to make sure
- that the record contains values identical to those
- specified by the terminal tool.
-
- If the validation fails, the Terminal Manager returns
- TRUE and the terminal tool fills the configuration
- record with default values by calling TMDefault.
- Your application can call this routine after
- restoring a configuration, to verify that the terminal
- record contains the correct information, in a manner
- similar to that shown next.
-
- BlockMove(saveConfig,hTerm.config,
- GetPtrSize(hTerm^^.config));
- IF TMValidate(hTerm) THEN BEGIN
- {validate failed}
- END
- ELSE BEGIN
- {validate succeeded}
- END
-
-
- æKY TMChoose
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32C (or #812)
- æDT TMChoose(VAR hTerm: TermHandle; where: Point; idleProc: ProcPtr): INTEGER;
- æC -----
- Configuring a terminal tool
-
- Function TMChoose(VAR hTerm: TermHandle; where: Point; idleProc:
- ProcPtr): INTEGER;
-
- Description: An application can configure a terminal tool in one of
- three ways. The easiest and most straightforward way is
- by calling the TMChoose routine. This routine presents
- the user with a dialog box.
- The second way an application can configure a
- terminal tool is by presenting the user with a custom
- tool-settings dialog box. This method is much more
- difficult and involves calling six routines. The
- routines are described in the next section, “Custom
- Configuration of a Terminal Tool,” and “The Custom
- Tool-Settings Dialog Box” in Appendix C provides
- example code.
- The third way your application can configure a
- terminal tool is by using the scripting language
- interface, described in “Interfacing with a Scripting
- Language,” later in this chapter. This method allows
- your application to bypass user interface elements.
-
- where is the point specified in global coordinates,
- where the upper-left corner of the dialog box should
- appear. It is recommended that your application place
- the dialog box as close to the upper-left corner of the
- screen as possible because the size of the dialog box
- varies from tool to tool.
-
- idleProc is a procedure with no parameters that the
- Terminal Manager will automatically call every time
- TMChoose loops through the setup dialog box filter
- procedure. Pass NIL if your application has no idleProc.
-
- TMChoose returns one of the following values:
-
- CONST
- chooseDisaster = -2;
- choose Failed = -1;
- chooseOKMinor = 1;
- chooseOKMajor = 2;
- chooseCancel = 3;
-
- chooseDisaster means that the TMChoose operation failed, destroyed
- the terminal record, and returned NIL in the terminal handle.
- chooseFailed means that the TMChoose operation failed and the
- terminal record was not changed.
- chooseOKMinor means that the user clicked OK in the dialog box, but
- did not change the terminal tool being used.
- chooseOKMajor means that the user clicked OK in the dialog box and
- also changed the terminal tool being used. The Terminal Manager then
- destroys the old terminal handle by calling TMDispose, and returns a new
- terminal handle in hTerm.
- chooseCancel means that the user clicked Cancel in the dialog box.
-
-
- æKY TMSetupPreflight
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$316 (or #790)
- æDT TMSetupPreflight(procID: INTEGER; VAR magicCookie: LONGINT): Handle;
- æC -----
- Setting up the custom tool-settings dialog box
-
- Function TMSetupPreflight(procID: INTEGER; VAR magicCookie:
- LONGINT): Handle;
-
- Description: TMSetupPreflight returns a handle to a dialog item list
- that your application appends to the tool-settings
- dialog box. The handle comes from the terminal tool.
- (The calling application uses AppendDITL, which is
- discussed in Chapter 7.) This handle is not a resource
- handle. Your application is responsible for disposing of
- the handle when done with it.
- The terminal tool can use TMSetupPreflight to
- allocate a block of private storage, and to store the
- pointer to that block in magicCookie. magicCookie should
- be passed to the other routines that are used to set up
- the custom tool-settings dialog box.
-
- procID is the ID for the terminal tool that is being
- configured. Your application should get this value by
- using the TMGetProcID routine, which is discussed
- earlier in this chapter.
-
- Note: The refcon of the custom tool-settings dialog
- box should point to a data structure (an example of
- which is shown next) in which the first two bytes are
- the tool procID and the next four bytes are magicCookie.
- UserItem routines, for example, may require procID to
- obtain tool resources.
-
-
- TYPE
- chooseDLOGdata = RECORD
- procID : INTEGER
- magicCookie : LONGINT
- END;
-
-
- æKY TMSetupSetup
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$317 (or #791)
- æDT TMSetupSetup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Setting up the custom tool-settings dialog box items
-
- Procedure TMSetupSetup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie:
- LONGINT);
-
- Description: TMSetupSetup tells the terminal tool to set up controls
- (like radio buttons or check boxes) in the dialog item
- list returned by TMSetupPreflight.
-
- procID is the ID for the terminal tool being configured.
- Your application should use the same value for procID as
- it passed to TMSetupPreflight.
-
- theConfig is a pointer to a configuration record for the
- tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box in which configuration is
- taking place.
-
- magicCookie is a pointer to private storage for the terminal tool.
-
-
- æKY TMSetupFilter
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$318 (or #792)
- æDT TMSetupFilter(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theEvent: EventRecord; VAR theItem: INTEGER; VAR magicCookie: LONGINT): BOOLEAN;
- æC -----
- Filtering custom tool-settings dialog box events
-
- Function TMSetupFilter(procID: INTEGER; theConfig: Ptr;
- count:INTEGER; theDialog: DialogPtr; VAR theEvent:
- EventRecord; VAR theItem: INTEGER; VAR magicCookie:
- LONGINT): BOOLEAN;
-
- Description: Your application calls TMSetupFilter as a filter
- procedure before it calls the standard modal dialog box
- filter procedure for the custom tool-settings dialog box.
- This routine allows terminal tools to filter events in
- the custom tool-settings dialog box.
-
- procID is the ID for the terminal tool that is being
- configured. Your application should use the same value
- for procID as it passed to TMSetupPreflight.
-
- theConfig is the pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theEvent is the event record for which filtering is to
- take place.
-
- theItem can return the item clicked in the dialog box.
-
- magicCookie is a pointer to private storage for the
- terminal tool.
-
- If the event passed in was handled, TMSetupFilter
- returns TRUE. Otherwise, FALSE indicates that your
- application should perform standard dialog box filtering.
-
-
- æKY TMSetupItem
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$319 (or #793)
- æDT TMSetupItem(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER; VAR magicCookie: LONGINT);
- æC -----
- Processing custom tool-settings dialog box events
-
- Procedure TMSetupItem(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER;
- VAR magicCookie: LONGINT);
-
- Description: TMSetupItem processes events for controls in the custom
- tool-settings dialog box.
-
- procID is the ID for the terminal tool being configured.
- Your application should use the same value for procID as
- it passed to TMSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theItem is the item clicked in the dialog box. This
- value can be modified and sent back.
-
- magicCookie is a pointer to private storage for the
- terminal tool.
-
-
- æKY TMSetupCleanup
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31A (or #794)
- æDT TMSetupCleanup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Performing clean-up operations
-
- Procedure TMSetupCleanup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie:
- LONGINT);
-
- Description: TMSetupCleanup disposes of any storage allocated in
- TMSetupPreflight and performs other clean-up operations.
- If your application needs to shorten a dialog box, it
- should do so after calling this routine.
-
- procID is the ID for the terminal tool that is being
- configured. Your application should use the same value
- for procID as it passed to TMSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- magicCookie is a pointer to private storage for the
- terminal tool.
-
-
- æKY TMSetupPostflight
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$331 (or #817)
- æDT TMSetupPostflight(procID: INTEGER);
- æC -----
- Closing the tool file
-
- Procedure TMSetupPostflight(procID:INTEGER);
-
- Description: TMSetupPostflight closes the tool file if it is not
- being used by any session.
-
- procID is the ID for the terminal tool that is being
- configured. Your application should use the same value
- for procID as it passed to TMSetupPreflight.
-
-
- æKY TMGetConfig
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31B (or #795)
- æDT TMGetConfig(hTerm: TermHandle): Ptr;
- æC -----
- Getting the configuration string
-
- Function TMGetConfig(hTerm: TermHandle): Ptr;
-
- Description: TMGetConfig gets a configuration string from the
- terminal tool.
-
- TMGetConfig returns a null-terminated, C-style string
- from the terminal tool containing tokens that fully
- describe the configuration of the terminal record.
- For an example, see the description of the next routine.
- If an error occurs, TMGetConfig returns NIL.
- It is the responsibility of your application to
- dispose of Ptr.
-
-
- æKY TMSetConfig
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31C (or #796)
- æDT TMSetConfig(hTerm: TermHandle; thePtr: Ptr): INTEGER;
- æC -----
- Setting the configuration with a string
-
- Function TMSetConfig(hTerm: TermHandle; thePtr: Ptr): INTEGER;
-
- Description: TMSetConfig passes a configuration string to the
- terminal tool.
-
- TMSetConfig passes a null-terminated, C-style string
- (see the example string later in this section) to the
- terminal tool for parsing. The string is pointed to
- by thePtr and must contain tokens that describe the
- configuration of the terminal record. The string can be
- any length.
-
- TMSetConfig ignores items it does not recognize or
- find relevant; such an occurrence causes the terminal
- tool to stop parsing the string and to return the
- character position where the error occurred. If the
- terminal tool successfully parses the string, it returns
- tmNoErr. If the terminal tool does not successfully
- parse the string, it returns one of the following values:
- a number less than –1 to indicate an OSErr, –1 to
- indicate an unknown error, or a positive number to
- indicate the character position where parsing was
- stopped.
- Individual terminal tools are responsible for the
- parsing operation.
-
- Sample: A null-terminated, C-style configuration string
-
- FontSize 9 Width 80 Cursor Underline Online True
- LocalEcho False AutoRepeat True RepeatControls False
- AutoWrap False NewLine False SmoothScroll False
- Transparent False SwapBSDelete False\0
-
-
- æKY TMStream
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30A (or #778)
- æDT TMStream(hTerm: TermHandle; theBuffer: Ptr; theLength: LONGINT; flags: CMFlags): LONGINT;
- æC -----
- Putting data into the terminal
-
- Function TMStream(hTerm: TermHandle; theBuffer: Ptr; theLength:
- LONGINT; flags: CMFlags): LONGINT;
-
- Description: Your application should use TMStream to give the
- terminal tool data to write into the terminal emulation
- buffer.
-
- TMStream returns the number of bytes that it processed.
-
- theBuffer is the data that is either to be placed in the
- terminal emulation buffer or processed by the terminal
- tool. Typically the data theBuffer points to has been
- provided by the connection tool your application is
- using.
-
- CMFlags is described under the description of CMRead in
- Chapter 3.
-
-
- æKY TMPaint
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$306 (or #774)
- æDT TMPaint(hTerm: TermHandle; theTermData:TermDataBlock; theRect: Rect);
- æC -----
- Drawing part of the terminal emulation region
-
- Procedure TMPaint(hTerm: TermHandle; theTermData:TermDataBlock;
- theRect: Rect);
-
- Description: TMPaint draws the data in theTermData into the rectangle
- theRect, which is in local window coordinates.
-
- theTermData.theData must be a handle to a block on the
- heap.
-
-
- æKY TMIdle
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$313 (or #787)
- æDT TMIdle(hTerm: TermHandle);
- æC -----
- Providing necessary idle time
-
- Procedure TMIdle(hTerm: TermHandle);
-
- Description: Your application should call TMIdle at least once every
- time it goes through its main event loop, so that the
- terminal tool can perform idle-loop tasks (like blinking
- the cursor or searching the terminal emulation buffer).
-
- hTerm specifies the terminal for which idle-loop tasks
- are to be performed.
-
-
- æKY TMGetLine
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$310 (or #784)
- æDT TMGetLine(hTerm: TermHandle; lineNo: INTEGER; VAR theTermData:TermDataBlock);
- æC -----
- Getting lines from the terminal emulation buffer
-
- Procedure TMGetLine(hTerm: TermHandle; lineNo: INTEGER; VAR
- theTermData:TermDataBlock);
-
- Description: TMGetLine returns a line from the terminal emulation
- buffer.
-
- lineNo specifies the line number of a line of data in
- the terminal emulation buffer. (Line numbering in the
- buffer begins with 1.)
-
- Your application must allocate theTermData.theData with
- a length of 0. For example, theTermData.theData:=
- NewHandle(0). The terminal tool copies the text into
- theTermData.theData, and increases the size of the
- handle if necessary. Your application is responsible for
- disposing of theTermData.theData.
-
-
- æKY TMScroll
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$312 (or #786)
- æDT TMScroll(hTerm: TermHandle; dH, dV: INTEGER);
- æC -----
- Scrolling the terminal emulation region
-
- Procedure TMScroll(hTerm: TermHandle; dH, dV: INTEGER);
-
- Description: TMScroll causes the terminal emulation region to scroll
- horizontally, vertically, or both.
-
- dH and dV specify the number of pixels to scroll
- horizontally and vertically. If your application
- specifies positive values for dH and dV, the terminal
- emulation region scrolls down and to the right. If your
- application specifies negative values, the terminal
- emulation region scrolls up and to the left.
-
-
- æKY TMClear
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30D (or #781)
- æDT TMClear(hTerm: TermHandle);
- æC -----
- Clearing the terminal emulation region
-
- Procedure TMClear(hTerm: TermHandle);
-
- Description: TMClear causes the terminal to clear the display screen
- and to place the cursor in the home position. Nothing is
- transmitted to the remote computer.
-
- If the tmSaveBeforeClear flag is on in the terminal
- record, the terminal tool caches the data that is
- cleared from the terminal emulation region.
-
-
- æKY TMReset
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30C (or #780)
- æDT TMReset(hTerm: TermHandle);
- æC -----
- Resetting the terminal
-
- Procedure TMReset(hTerm: TermHandle);
-
- Description: When your application calls TMReset, the terminal tool
- puts the specified terminal into a state that appears as
- if the terminal had just been turned on. In actuality,
- the screen representation structure and internal state
- tables (if the tool has any) are reset to the values
- specified by the terminal tool, and the configuration
- record for the terminal is reset to its last saved state.
-
- If the tmSaveBeforeClear flag is on in the terminal
- record, the terminal tool caches the data that is
- cleared from the terminal emulation region prior to
- resetting the terminal.
-
-
- æKY TMResize
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30E (or #782)
- æDT TMResize(hTerm: TermHandle; newTermRect: Rect);
- æC -----
- Resizing the terminal region
-
- Procedure TMResize(hTerm: TermHandle; newTermRect: Rect);
-
- Description: TMResize resizes the terminal emulation region to the
- coordinates specified in newTermRect.
-
- newTermRect specifies bounds of the new termRect. The
- terminal tool automatically resizes the value of
- viewRect.
-
-
- æKY TMDispose
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$303 (or #771)
- æDT TMDispose(hTerm: TermHandle);
- æC -----
- Disposing of a terminal record
-
- Procedure TMDispose(hTerm: TermHandle);
-
- Important: Your application must call TMDispose before
- disposing of the terminal emulation window with
- DisposeWindow. Since DisposeWindow clears all controls
- in the control list, a subsequent call to TMDispose may
- cause problems.
-
- Description: TMDispose disposes of the terminal record and all
- associated data structures and controls.
-
-
- æKY TMAddSearch
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$327 (or #807)
- æDT TMAddSearch(hTerm: TermHandle; theString: Str255; where: Rect; searchType: TMSearchTypes; callBack: ProcPtr): INTEGER;
- æC -----
- Adding a data stream search
-
- Function TMAddSearch(hTerm: TermHandle; theString: Str255; where:
- Rect; searchType: TMSearchTypes; callBack: ProcPtr):
- INTEGER;
-
- Description: TMAddSearch tells the terminal tool to search for a
- specified string.
-
- If the search was successfully added, this function
- returns the reference number assigned to the search. If
- the search was not successfully added, TMAddSearch
- returns –1. The tool searches for theString in the area
- specified by where and within the selection specified by
- searchType.
-
- where is a rectangle that contains two row/column pairs,
- with row and column numbers starting at 1.
- By specifying a –1 as a value in the row/column
- pairs, your application can limit the search to one row,
- one column, or the intersection of one row and one
- column. Table 4-1 shows how your application can use –1
- as a search-area delimiter.
-
- Table 4-1 TMAddSearch search-area delimiters
-
- ________________________________ ________________________________
- Area to search Row/column pair to use
- ________________________________ ________________________________
- rectangle bounded by n,m,o,p (n,m) (o,p)
- row n, any column (n,–1) (–1,–1)
- any row, column m (–1,m) (–1,–1)
- rows n - o (inclusive), any column (n,–1) (o,–1)
- column m - p (inclusive), any row (–1,m) (–1,p)
- anywhere (any row, any column) (–1,–1) (–1,–1)
- ________________________________ ________________________________
-
-
- Your application should pass in searchType the sum of
- three values that describes the search: searchNoDiacrit
- (to ignore diacritical marks), searchNoCase (to ignore
- case), and one of the constants that describes the
- selection.
-
- Valid values are as follows:
-
- TYPE
- TMSearchTypes = INTEGER;
-
- CONST
- { search modifiers }
- searchNoDiacrit = $0100;
- searchNoCase = $0200;
-
- { constants that describe the selection }
- selTextNormal = $0001;
- selTextBoxed = $0002;
- selGraphicsMarquee = $0004;
- selGraphicsLasso = $0008;
-
- callBack is a procedure that the tool automatically
- calls when it finds a match.
- callBack must be supplied by your application, and
- is described later in this chapter in the section
- “Routines That Must Be in Your Application.”
-
-
- æKY TMRemoveSearch
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$328 (or #808)
- æDT TMRemoveSearch(hTerm: TermHandle; refNum: INTEGER);
- æC -----
- Stopping a data stream search
-
- Procedure TMRemoveSearch(hTerm: TermHandle; refNum: INTEGER);
-
- Description: TMRemoveSearch stops the search specified by refNum.
-
- This routine cannot be called at interrupt level, but
- can be called by MyCallBack. (MyCallBack is discussed
- later in this chapter under “Routines That Must Be in
- Your Application.”)
-
-
- æKY TMClearSearch
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$329 (or #809)
- æDT TMClearSearch(hTerm: TermHandle);
- æC -----
- Clearing all data stream searches
-
- Procedure TMClearSearch(hTerm: TermHandle);
-
- Description: TMClearSearch stops all searches associated with the
- specified terminal record.
-
- hTerm specifies the terminal record. TMClearSearch
- cannot be called from interrupt level.
-
-
- æKY TMSetSelection
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$311 (or #785)
- æDT TMSetSelection(hTerm: TermHandle; theSelection: TMSelection; selType: TMSelTypes);
- æC -----
- Setting and highlighting selections
-
- Procedure TMSetSelection(hTerm: TermHandle; theSelection:
- TMSelection; selType: TMSelTypes);
-
- Description: TMSetSelection makes theSelection the current selection.
-
- selType determines the type of highlighting for the
- selection. Valid values are:
-
- TYPE
- TMSelTypes = INTEGER;
-
- CONST
- selTextNormal = $0001;
- selTextBoxed = $0002;
- selGraphicsMarquee = $0004;
- selGraphicsLasso = $0008;
-
-
- æKY TMGetSelect
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30F (or #783)
- æDT TMGetSelect(hTerm: TermHandle; theData: Handle; VAR theType: ResType): LONGINT;
- æC -----
- Getting data from a selection
-
- Function TMGetSelect(hTerm: TermHandle; theData: Handle;
- VAR theType: ResType): LONGINT;
-
- Description: TMGetSelect returns either the number of bytes in the
- selection, or an appropriate operating system error code.
-
- If nothing is selected, TMGetSelect returns 0.
- Otherwise, it returns the size of the selected data.
-
- theData must be a handle to a block of size 0.
- TMGetSelect will resize this block as necessary.
-
- theType specifies the type of data this routine returns.
- If theType is TEXT, theData is a handle to textual data.
- theType and theData may be passed directly to the Scrap
- Manager.
-
-
- æKY TMActivate
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$307 (or #775)
- æDT TMActivate(hTerm: TermHandle; activate: BOOLEAN);
- æC -----
- Activate events
-
- Procedure TMActivate(hTerm: TermHandle; activate: BOOLEAN);
-
- Description: TMActivate processes an activate or deactivate event
- (for instance, installing or removing a custom tool
- menu) for a window associated with the terminal tool.
-
- If activate is TRUE, the terminal tool processes an
- activate event. Otherwise, it processes a deactivate
- event.
-
-
- æKY TMResume
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$308 (or #776)
- æDT TMResume(hTerm: TermHandle; resume: BOOLEAN);
- æC -----
- Resume events
-
- Procedure TMResume(hTerm: TermHandle; resume: BOOLEAN);
-
- Description: TMResume processes a resume or suspend event for a
- terminal window. Resume and suspend events are processed
- only if a tool has a custom menu to install or remove
- from the menu bar.
-
- If resume is TRUE, then the terminal processes a resume
- event. Otherwise, it processes a suspend event.
-
-
- æKY TMMenu
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$30B (or #779)
- æDT TMMenu(hTerm: TermHandle; menuID: INTEGER; item: INTEGER): BOOLEAN;
- æC -----
- Menu events
-
- Function TMMenu(hTerm: TermHandle; menuID: INTEGER; item:
- INTEGER): BOOLEAN;
-
- Description: Your application must call TMMenu when the user chooses
- an item from a menu that is installed by the terminal
- tool.
-
- TMMenu returns FALSE if the terminal tool did not handle
- the menu event. TMMenu returns TRUE if the terminal tool
- did handle the menu event.
-
-
- æKY TMClick
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$309 (or #777)
- æDT TMClick(hTerm: TermHandle; theEvent: EventRecord);
- æC -----
- Mouse events
-
- Procedure TMClick(hTerm: TermHandle; theEvent: EventRecord);
-
- Description: TMClick processes a mouseDown vent in the terminal
- emulation region. The routine pointed to by myclikLoop,
- discussed later in this chapter in the section “Routines
- That Must Be in Your Application,” is called repeatedly
- by TMClick.
-
-
- æKY TMKey
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$304 (or #772)
- æDT TMKey(hTerm: TermHandle; theEvent: EventRecord);
- æC -----
- Keyboard events
-
- Procedure TMKey(hTerm: TermHandle; theEvent: EventRecord);
-
- Description: TMKey processes a keyDown or autoKey event. The terminal
- tool translates the keystroke into a sequence of bytes.
- The terminal tool then calls your application’s sendProc
- routine (discussed later in this chapter under “Routines
- That Must Be in Your Application.”) to transmit this
- sequence of bytes.
-
- Your application can create its own event record for
- specific keyboard events by filling in the event record
- with the character code and –1 for the key code in the
- message field.
-
-
- æKY TMUpdate
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$305 (or #773)
- æDT TMUpdate(hTerm: TermHandle; visRgn: RgnHandle);
- æC -----
- Update events
-
- Procedure TMUpdate(hTerm: TermHandle; visRgn: RgnHandle);
-
- Description: Your application will typically call TMUpdate between
- BeginUpdate and EndUpdate.
-
- visRgn specifies the region to be updated.
-
-
- æKY TMEvent
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32D (or #813)
- æDT TMEvent(hTerm: TermHandle; theEvent: EventRecord);
- æC -----
- Other events
-
- Procedure TMEvent(hTerm: TermHandle; theEvent: EventRecord);
-
- Description: When your application receives an event, it should check
- whether the refcon of the window is a tool’s hTerm. Such
- an event occurs, for example, when the user clicks a
- button in a dialog box displayed by the terminal tool.
- If it does belong to a terminal tool’s window, your
- application can call TMEvent.
-
- A window (or dialog box) created by a terminal tool has
- a terminal record handle stored in the refCon field for
- windowRecord.
-
-
- æKY TMIntlToEnglish
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31D (or #797)
- æDT TMIntlToEnglish(hTerm: TermHandle; inputPtr: Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
- æC -----
- Translating into English
-
- Function TMIntlToEnglish(hTerm: TermHandle; inputPtr: Ptr;
- VAR outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: TMIntlToEnglish converts a configuration string, which
- is pointed to by inputPtr, to an American English
- configuration string pointed to by outputPtr.
-
- The function returns an operating system error code if
- any internal errors occur.
- The terminal tool allocates space for outputPtr.
- Your application should dispose of this pointer when
- done with it.
- language specifies the language from which the
- string is to be converted. Valid values for this field
- are shown in the description of the Script Manager in
- Inside Macintosh, Volume V. If the language specified is
- not supported, this routine returns tmNoErr, but
- outputPtr is NIL.
-
-
- æKY TMEnglishToIntl
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$31E (or #798)
- æDT TMEnglishToIntl(hTerm: TermHandle; inputPtr: Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
- æC -----
- Translate from English
-
- Function TMEnglishToIntl(hTerm: TermHandle; inputPtr: Ptr;
- VAR outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: TMEnglishToIntl converts an American English
- configuration string, which is pointed to by inputPtr,
- to a configuration string pointed to by outputPtr.
-
- The function returns an operating system error code if
- any internal errors occur.
- The terminal tool allocates space for outputPtr.
- Your application is responsible for disposing of the
- pointer with DisposPtr when done with it.
- language specifies the language to which the string
- is to be converted. Valid values for this field are
- shown in the description of the Script Manager in
- Inside Macintosh, Volume V. If the language specified
- is not supported, tmNoErr is still returned, but
- outputPtr is NIL.
-
-
- æKY TMGetToolName
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$320 (or #800)
- æDT TMGetToolName(procID: INTEGER; VAR name: Str255);
- æC -----
- Getting the name of a tool
-
- Procedure TMGetToolName(procID: INTEGER; VAR name: Str255);
-
- Description: TMGetToolName returns in name the name of the tool
- specified by procID.
-
- If procID references a terminal tool that does not
- exist, the Terminal Manager sets name to an empty
- string.
-
-
- æKY TMSetRefCon
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$321 (or #801)
- æDT TMSetRefCon(hTerm: TermHandle; refCon: LONGINT);
- æC -----
- Setting the terminal tool's reference constant
-
- Procedure TMSetRefCon(hTerm: TermHandle; refCon: LONGINT);
-
- Description: TMSetRefCon sets the terminal record’s refCon to the
- specified value. It is very important that your
- application use this routine to change the value of the
- reference constant, instead of changing it directly.
-
-
- æKY TMGetRefCon
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$322 (or #802)
- æDT TMGetRefCon(hTerm: TermHandle): LONGINT;
- æC -----
- Getting the terminal tool's reference constant
-
- Function TMGetRefCon(hTerm: TermHandle): LONGINT;
-
- Description: TMGetRefCon returns the terminal record’s reference
- constant.
-
-
- æKY TMSetUserData
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$323 (or #803)
- æDT TMSetUserData(hTerm: TermHandle; userData: LONGINT);
- æC -----
- Setting the userData field
-
- Procedure TMSetUserData(hTerm: TermHandle; userData: LONGINT);
-
- Description: TMSetUserData sets the terminal record’s userData field
- to the value specified by userData. It is very important
- that your application use this routine to change the
- value of the userData field, instead of changing it
- directly.
-
-
- æKY TMGetUserData
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$324 (or #804)
- æDT TMGetUserData(hTerm: TermHandle): LONGINT;
- æC -----
- Getting the userData field
-
- Function TMGetUserData(hTerm: TermHandle): LONGINT;
-
- Description: TMGetUserData returns the terminal record’s userData
- field.
-
-
- æKY TMGetVersion
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$325 (or #805)
- æDT TMGetVersion(hTerm: TermHandle): Handle;
- æC -----
- Getting 'vers' resource information
-
- Function TMGetVersion(hTerm: TermHandle): Handle;
-
- Description: TMGetVersion returns a handle to a relocatable block
- that contains the information that is in the terminal
- tool’s 'vers' resource with ID=1. Your application is
- responsible for disposing of the handle when done with
- it.
-
- Note: The handle returned is not a resource handle.
-
-
- æKY TMGetTMVersion
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$326 (or #806)
- æDT TMGetTMVersion: INTEGER;
- æC -----
- Getting the Terminal Manager version number
-
- Function TMGetTMVersion: INTEGER;
-
- Description: TMGetTMVersion returns the version number of the
- Terminal Manager.
-
- The version number of the Terminal Manager described in
- this document is:
-
- CONST
- curTMVersion = 1;
-
-
- æKY TMGetCursor
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32A (or #810)
- æDT TMGetCursor(hTerm: TermHandle; cursType: TMCursorTypes): Point;
- æC -----
- Getting the current cursor position
-
- Function TMGetCursor(hTerm: TermHandle; cursType: TMCursorTypes):
- Point;
-
- Description: TMGetCursor returns the current position of the cursor.
- Numbering of rows and columns begins with 1.
-
- Valid values for cursType are as follows:
-
- CONST
- cursorText = 1;
- cursorGraphics = 2;
-
- TYPE
-
- TMCursorTypes = INTEGER;
-
- For cursorText, the position returned is in
- row/column format, and for cursorGraphics the position
- is in pixel coordinates.
-
-
- æKY TMDoTermKey
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32E (or #814)
- æDT TMDoTermKey(hTerm: TermHandle; theKey: Str255): BOOLEAN;
- æC -----
- Emulating a special terminal key
-
- Function TMDoTermKey(hTerm: TermHandle; theKey: Str255): BOOLEAN;
-
- Description: TMDoTermKey emulates a special terminal key specified by
- theKey.
-
- If the terminal tool does not understand the key
- specified by theKey, this routine returns FALSE.
- Otherwise, if the key specified is processed, this
- routine returns TRUE.
- For information about the terminal keys supported by
- a terminal tool, refer to that tool’s documentation.
-
- This example shows how an application can use
- TMDoTermKey to emulate the user’s pressing a PF1 key:
-
- IF TMDoTermKey(hTerm, 'PF1') THEN
- BEGIN
- END;
-
-
- æKY TMCountTermKeys
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32F (or #815)
- æDT TMCountTermKeys(hTerm): INTEGER;
- æC -----
- Counting special terminal keys
-
- Function TMCountTermKeys(hTerm): INTEGER;
-
- Description: TMCountTermKeys returns the number of special terminal
- keys that the terminal tool supports.
-
- TMCountTermKeys returns 0 if the terminal tool supports
- no special terminal keys.
-
-
- æKY TMGetIndTermKey
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$330 (or #816)
- æDT TMGetIndTermKey(hTerm:TermHandle; id:INTEGER; VAR theKey:Str255);
- æC -----
- Getting a terminal key
-
- Procedure TMGetIndTermKey(hTerm:TermHandle; id:INTEGER;
- VAR theKey:Str255);
-
- Description: TMGetIndTermKey returns the name of a specified key.
-
- TMGetIndTermKey returns in theKey the terminal key
- specified by id. If id specifies a key that does not
- exist, this routine returns an empty string.
-
-
- æKY TMGetTermEnvirons
- æFa Terminals.a
- æFc Terminals.h
- æFp Terminals.p
- æMM
- æTN $A08B A0^.w=$32B (or #811)
- æDT TMGetTermEnvirons(hTerm: TermHandle; VAR theEnvirons: TermEnvironRec): TMErr;
- æC -----
- Getting general terminal tool information
-
- Function TMGetTermEnvirons(hTerm: TermHandle; VAR theEnvirons:
- TermEnvironRec): TMErr;
-
- Description: TMGetTermEnvirons returns theEnvirons, which reflects
- the internal conditions of the terminal tool. The caller
- of this routine must fill in the version field of
- theEnvirons before calling TMGetTermEnvirons.
-
- This routine returns tmNoErr, envVersTooBig, or an
- operating system error code. The fields in theEnvirons
- are as follows:
-
- TYPE
- TermEnvironPtr = ^TermEnvironRec;
- TermEnvironRec = RECORD
- version : INTEGER;
- termType : TMTermTypes;
- textRows : INTEGER;
- textCols : INTEGER;
- cellSize : Point;
- graphicSize : Rect;
- slop : Point;
- auxSpace : Rect;
- END;
-
-
- version is the version number of the requested terminal
- environment record, which is curTermEnvRecVers in this
- release of the Terminal Manager. The caller of the
- routine must fill in this field before calling
- TMGetTermEnvirons.
-
- termType is the type of terminal. termType can contain
- one or both of the following values:
-
- CONST
- tmTextTerminal = $0001;
- tmGraphicsTerminal = $0002;
-
- curTermEnvRecVers = 0;
-
- TYPE
- TMTermTypes = INTEGER;
-
- textRows is the number of rows in the terminal emulation
- region. The first row is row number 1.
-
- textCols is the number of columns in the terminal
- emulation region. The first column is column number 1.
-
- cellSize is the height and width of each cell.
-
- graphicSize is the size of the default rectangle of the
- graphics terminal tool measured in pixels.
-
- slop is the border of the terminal emulation region.
-
- auxSpace is a rectangle that specifies any additional
- space that is required at the top, bottom, right, or
- left of the terminal emulation region.
-
- Result Codes tmGenericError, tmNoErr, tmNotSupported, envVersTooBig.
-
-
- æKY sendProc
- æDT MySendProc(thePtr: Ptr; theSize: LONGINT; refCon: LONGINT; flags: CMFlags): LONGINT;
- æC -----
- Sending data out along the connection
-
- Function MySendProc (thePtr: Ptr; theSize: LONGINT; refCon:
- LONGINT; flags: CMFlags): LONGINT;
-
- Description: When a tool needs to send data to another entity, it
- looks to your application to provide MySendProc.
- MySendProc may simply be the routine that the Connection
- Manager uses to send data (as is the case in the next
- example), or it can be a routine that you have written.
-
- thePtris a pointer to the data to be sent.
-
- theSize is the number of characters to be sent.
-
- refCon is the reference constant field for sending
- terminal’s terminal.
-
- MySendProc returns the actual number of characters sent.
-
- flags indicates whether the connection tool should send
- an end-of-message indicator. An end-of-message indicator
- needs to be supported by the particular communications
- protocol being used; if an end-of-message indicator is
- not supported by the connection protocol, your
- application should ignore this field.
-
-
- Sample routine for sending data
- FUNCTION MySendProc(thePtr: Ptr;theSize: LONGINT;
- refcon: LONGINT;flags: INTEGER): LONGINT;
- VAR
- theErr: CMErr; { Any errors }
-
- BEGIN
- MySendProc := 0; { Assume the worst }
-
- IF gConn <> NIL THEN BEGIN
-
-
- { DO NOT check to see if the connection is first open before sending }
- { as the tool might be handling the data locally }
-
- { Send the data }
- theErr := CMWrite(gConn, thePtr, theSize, cmData, FALSE, NIL, 0, flags);
- IF (theErr = noErr) THEN
- MySendProc := theSize { If ok, we sent all }
- ELSE
- ; { Handle errors }
- END; { Good Connection }
-
- END; { MySendProc }
-
-
- æKY MyBreakProc
- æC -----
- Sending a break
-
- Procedure MyBreakProc(duration: LONGINT; refCon: LONGINT);
-
- Description: Your application needs to contain information about how
- to send a break on a connection. Although it can contain
- the code that performs the break operation, your
- application can also point to a connection tool routine
- that performs the break. This section gives an example.
-
- duration specifies, in ticks, how long the break should
- last.
-
- refCon is the reference constant field of the terminal
- record.
-
- Sample showing how to break a connection
-
- PROCEDURE MyBreakProc(duration: LONGINT; refcon : LONGINT);
- BEGIN
- { Here we choose to issue a synchronous break }
- IF gConn <> NIL THEN
- CMBreak(gConn, duration, FALSE, NIL);
- END; { MyBreakProc }
-
-
- æKY MyCacheProc
- æC -----
- Caching lines from the terminal region
-
- Function MyCacheProc(refCon: LONGINT; theTermData:TermDataBlock):
- LONGINT;
-
- Description: Your application can cache lines that scroll off the top
- of the terminal emulation region and, if desired,
- display them in the terminal emulation window. If you
- want your application to display these lines, you have
- to provide the necessary code. If you do not want your
- application to display these lines, then your
- application should specify NIL for MyCacheProc when it
- calls TMNew.
-
- MyCacheProc must return tmNoErr if no error occurred
- during processing. Otherwise, it should return an
- appropriate error code.
-
- refCon is the reference constant for the terminal record.
-
- theTermData is a data structure of type TermDataBlock:
-
- TYPE
- TermDataBlockH = ^TermDataPtr;
- TermDataBlockPtr = ^TermDataBlock;
- TermDataBlock = RECORD
- flags : TMTermTypes;
- theData : Handle;
- auxData : Handle;
- reserved : LONGINT;
- END;
-
- theTerm.theData is a handle to a block on the heap.
- Your application can calculate the size of this block
- with GetHandleSize. Your application must copy any data
- it needs because theTermData belongs to the terminal
- tool and may not exist after MyCacheProc has finished.
- Your application can use HandToHand to copy the data.
-
- Sample showing how to cache lines
-
- FUNCTION MyCacheProc (refcon : LONGINT; theTermData : TermDataBlock )
- : LONGINT;
- VAR
- sizeCached : LONGINT;
-
- BEGIN
- { Check for data integrity }
- IF (theTermData.theData = NIL) THEN BEGIN
- MyCacheProc := -1;
- EXIT(MyCacheProc);
- END; { Bad Data }
-
- { Cache either graphics or text }
- HLock(theTermData.theData);
-
- { Get rid of the old cached data }
- IF (gCache <> NIL) THEN
- DisposHandle(gCache);
-
- { make a copy of new text }
- gCache := theTermData.theData;
- IF (HandToHand(gCache) <> noErr) THEN BEGIN
- gCache := NIL; (* Handle errors *)
- sizeCached := -1;
- END
- ELSE
- sizeCached := GetHandleSize(gCache);
-
- HUnlock(theTermData.theData);
-
- IF (theTermData.flags = tmGraphicsTerminal) THEN BEGIN
- { theTermData.theData is a handle to a QD Picture }
- (*
- Could save it as PICT
- *)
- END { cache graphics }
- ELSE IF (theTermData.flags = tmTextTerminal) THEN BEGIN
- { theTermData.theData is a handle to text }
-
- (*
- Could write it out to the data fork
- *)
- END; { cache text }
- MyCacheProc := sizeCached;
- END; { MyCacheProc }
-
-
- æKY MyCallBack
- æC -----
- Responding to a matched search parameter
-
- Procedure MyCallBack(hTerm: TermHandle; refNum: INTEGER;
- foundRect: Rect);
-
- Description: Your application can selectively filter data in the
- terminal emulation buffer by making use of a search
- call-back procedure. Since a tool will automatically
- call MyCallBack when it finds a match to the search
- string, your application can respond in any way that you
- want it to.
-
- refNum is the reference number associated with a
- particular search. Reference numbers are assigned by the
- Terminal Manager when a search is added to a terminal
- record with the TMAddSearch routine.
-
- foundRect describes in row/column format where the match
- was found, with row and column numbers starting at 1.
-
-
- æKY MyClikLoop
- æC -----
- Responding to mouse clicks
-
- Function MyClikLoop(refCon: LONGINT): BOOLEAN;
-
- Description: This routine is called when the user is dragging the
- mouse in the terminal emulation window. Initially, your
- application should process a mouse-down event by calling
- TMClick, which in turn calls this routine.
-
- This routine returns TRUE when the mouse is clicked
- within the cache region. Otherwise, it returns FALSE.
-
-
- æKY environsProc
- æC -----
- Getting connection environment information
-
- Function MyEnvironsProc(refCon: LONGINT; VAR theEnvirons:
- ConnEnvironRec): CMErr;
-
- Description: To get information about the connection environment, the
- terminal tool calls a routine in your application,
- MyEnvironsProc.
-
- refCon is the reference constant for the terminal tool.
-
- theEnvirons is a data structure containing the
- connection-environment record. Your application can
- either construct theEnvirons or use the Connection
- Manager routine CMGetConnEnvirons. For more information
- about theEnvirons , see “CMGetConnEnvirons” in Chapter 3.
- The example that follows shows how MyEnvironsProc
- can point to a Connection Manager routine to retrieve
- information about the connection environment.
-
- Sample terminal-environment routine
-
- FUNCTION MyEnvironsProc(refCon: LONGINT;VAR theEnvirons:
- ConnEnvironRec): OSErr;
- BEGIN
- MyEnvironsProc:= envNotPresent; { pessimism }
- theEnvirons.version := curConnEnvRecVers;
- { fill in version field }
-
- IF (gConn <> NIL) THEN { Tool sets the version }
- MyEnvironsProc:= CMGetConnEnvirons(gConn,theEnvirons);
-
- END; { MyEnvironsProc }
-
-
- æKY File Transfer Manager
- æC -----
- FTAbort FTMenu
- FTActivate FTNew
- FTChoose FTResume
- FTDefault FTSetConfig
- FTDispose FTSetRefCon
- FTEnglishToIntl FTSetupCleanup
- FTEvent FTSetupFilter
- FTExec FTSetupItem
- FTGetConfig FTSetupPostFlight
- FTGetFTVersion FTSetupPreFlight
- FTGetProcID FTSetupSetup
- FTGetRefCon FTSetUserData
- FTGetToolName FTStart
- FTGetUserData FTValidate
- FTGetVersion InitFT
- FTIntlToEnglish
-
- FTRecord
-
-
- æKY FileTransfers
- æC -----
- FTAbort FTMenu
- FTActivate FTNew
- FTChoose FTResume
- FTDefault FTSetConfig
- FTDispose FTSetRefCon
- FTEnglishToIntl FTSetupCleanup
- FTEvent FTSetupFilter
- FTExec FTSetupItem
- FTGetConfig FTSetupPostFlight
- FTGetFTVersion FTSetupPreFlight
- FTGetProcID FTSetupSetup
- FTGetRefCon FTSetUserData
- FTGetToolName FTStart
- FTGetUserData FTValidate
- FTGetVersion InitFT
- FTIntlToEnglish
-
- FTRecord
-
-
- æKY FTMgr
- æC -----
- FTAbort FTMenu
- FTActivate FTNew
- FTChoose FTResume
- FTDefault FTSetConfig
- FTDispose FTSetRefCon
- FTEnglishToIntl FTSetupCleanup
- FTEvent FTSetupFilter
- FTExec FTSetupItem
- FTGetConfig FTSetupPostFlight
- FTGetFTVersion FTSetupPreFlight
- FTGetProcID FTSetupSetup
- FTGetRefCon FTSetUserData
- FTGetToolName FTStart
- FTGetUserData FTValidate
- FTGetVersion InitFT
- FTIntlToEnglish
-
- FTRecord
-
-
- æKY FTRecord
- æC -----
- FTHandle = ^FTPtr;
- FTPtr = ^FTRecord;
- FTRecord = PACKED RECORD
- procID : INTEGER;
- flags : FTFlags;
- errCode : FTErr;
- refCon : LONGINT;
- userData : LONGINT;
- defProc : ProcPtr;
- config : Ptr;
- oldConfig : Ptr;
- environsProc : ProcPtr;
- reserved1 : LONGINT;
- reserved2 : LONGINT;
- ftPrivate : Ptr;
- sendProc : ProcPtr;
- recvProc : ProcPtr;
- writeProc : ProcPtr;
- readProc : ProcPtr;
- owner : WindowPtr;
- direction : FTDirection;
- theReply : SFReply;
- writePtr : LONGINT;
- readPtr : LONGINT;
- theBuf : ^char;
- bufSize : LONGINT;
- autoRec : Str255;
- attributes : FTAttributes;
- END;
-
- procID
- procID is the file transfer tool ID. This value is dynamically
- assigned by the File Transfer Manager when your application calls
- FTGetProcID.
-
-
- flags
- flags is a bit field that your application can use to determine when
- a file transfer has finished, and if the file transfer was successful.
- Valid values are as follows:
-
- CONST
- ftIsFTMode = $00000001;
- ftNoMenus = $00000002;
- ftQuiet = $00000004;
- ftSucc = $00000080;
-
- TYPE
- FTFlags = LONGINT;
-
- ftIsFTMode indicates whether a file transfer is in progress. A tool
- turns this bit on just prior to performing the actual file transfer, and
- turns it off when the file transfer stops.
- The file transfer tool will not display any custom menus if your
- application sets the ftNoMenus bit. The file transfer tool will not
- display any status dialog boxes or error alerts if your application sets
- the ftQuiet bit. If your application turns ftQuiet on, it is responsible
- for displaying status dialog boxes and error alerts that the tool would
- have displayed. Applications typically use these two bits to hide the
- file transfer tool from the user.
- ftSucc is a bit set by the file transfer tool when a file transfer
- is completed successfully.
- Your application can first check to see if ftIsFTMode toggles from
- on to off to find out when the file transfer has been completed. Then,
- it can check ftSucc to see if the file transfer was completed
- successfully.
- The other bits of flags are reserved by Apple Computer, Inc.
-
-
- errCode
- errCode contains the last error reported to the File Transfer
- Manager. If errCode is negative, an operating system error occurred. If
- errCode is positive, a File Transfer Manager error occurred. Valid
- values are as follows:
-
- CONST
- ftGenericError = -1;
- ftNoErr = 0;
- ftRejected = 1;
- ftFailed = 2;
- ftTimeOut = 3;
- ftTooManyRetry = 4;
- ftNotEnoughDspace = 5;
- ftRemoteCancel = 6;
- ftWrongFormat = 7;
- ftNoTools = 8;
- ftUserCancel = 9;
- ftNotSupported = 10;
-
- TYPE
- FTErr = OSErr;
-
-
- refCon
- refCon is a four-byte field that your application can use.
-
-
- userData
- userData is a four-byte field that your application can use.
-
-
- defProc
- defProc is a pointer to the file transfer tool’s main definition
- procedure, which is contained in a code resource of type 'fdef' .
-
-
- config
- config is a pointer to a data block that is private to the file
- transfer tool. It can contain information like retry and timeout values,
- but the contents vary from tool to tool.
- Your application can store the contents of config to save the state
- of a file transfer in a document. The structure, size, and contents of
- the configuration record are set by the tool. Your application can
- determine the size of the configuration record by calling GetPtrSize,
- overwrite its contents using BlockMove, and validate the contents with
- FTValidate.
- Your application can use FTGetConfig and FTSetConfig to manipulate
- fields in this record. For details, read “Interfacing with a Scripting
- Language,” later in this chapter. Your application can save the state of
- the file transfer record by saving the string FTGetConfig returns. Also,
- your application can restore the configuration of the file transfer
- record by passing a saved string to FTSetConfig. You can find a
- description of config from a file transfer tool perspective in
- Chapter 8.
-
-
- oldConfig
- oldConfig is a pointer to a data block that is private to the file
- transfer tool and contains the most recently saved version of config.
- Your application is responsible for setting oldConfig when the user
- saves a session document.
-
-
- environsProc
- environsProc is a pointer to a routine in your application that the
- file transfer tool calls to obtain a record describing the connection
- environment. For more information about environsProc, see
- “MyEnvironsProc Getting Connection Environment Information,” later in
- this chapter.
-
-
- reserved1 and reserved2
- reserved1 and reserved2 are fields reserved for the File Transfer
- Manager. Your application must not use this field.
-
-
- ftPrivate
- ftPrivate is a pointer to a data block that is private to the file
- transfer tool. Your application must not use this field.
-
-
- sendProc
- sendProc is a pointer to a routine that your application uses to send
- data. This routine is discussed under “MySendProc Sending Data, ” later
- in this chapter.
-
-
- recvProc
- recvProc is a pointer to a routine that your application uses to
- request data. This routine is discussed under “MyRecvProc Receiving
- Data,” later in this chapter.
-
-
- writeProc
- writeProc is a pointer to a routine in your application that writes
- data to a file. If this field is NIL, the file transfer tool performs
- standard file operations (that is, writing to a disk). The file transfer
- tool checks this field to see if your application has a writeProc
- routine. If it does, the tool lets writeProc handle writing data.
- This routine can be used to perform postprocessing upon a file being
- received, and is discussed under “MyWriteProc Writing Data,” later in
- this chapter.
-
-
- readProc
- readProc is a pointer to a routine in your application that reads
- data from a file. If this field is NIL, the file transfer tool performs
- standard file operations (that is, reading data from a disk). The file
- transfer tool checks this field to see if your application has a
- readProc routine. If it does, the tool lets readProc handle reading data.
- This routine can be used to perform preprocessing upon a file being
- sent, and is discussed under “MyReadProc Reading Data,” later in this
- chapter.
-
-
- owner
- owner is a pointer to a window (or grafPort) relative to which the
- file transfer status dialog box is positioned. If this field is NIL, the
- file transfer tool will not display a file transfer status dialog box.
-
-
- direction
- direction is a field that indicates whether a file is being sent to
- or received from another entity. Your application passes this field as a
- parameter to FTStart (described later in this chapter). Valid values in
- this field are as follows:
-
- CONST
- ftReceiving = 0;
- ftTransmitting = 1;
- ftFullDuplex = 2;
-
- TYPE
- FTDirection = INTEGER;
-
-
- theReply
- theReply is an SFReply data structure. The SFReply data structure
- should contain the reference number of the working directory of the
- default volume for files being sent or received. If a file is being
- sent, the data structure should also contain the name of the file to be
- sent. If a file is being received and your application has information
- about the filename (for example, from a scripting language), the data
- structure should contain the filename to be used. Otherwise, pass an
- empty string for theReply.filename.
-
-
- writePtr, readPtr, theBuf, and bufSize
- writePtr, readPtr, theBuf, and bufSize are properties of a particular
- file transfer tool.
-
-
- autoRec
- autoRec is a string that represents the start sequence a remote
- entity sends, causing the Macintosh to enter a file-reception mode. If
- this string is of length 0, remote-entity-initiated file transfers are
- not supported by the file transfer tool. It is the application’s
- responsibility to make use of this field by searching the data stream
- for this sequence of characters. The Connection Manager, described in
- Chapter 3, provides routines that your application can use to search an
- incoming data stream for a specified sequence of characters.
-
-
- attributes
- attributes is a field that describes the file transfer protocol
- supported by the file transfer tool. The bits in attributes are as
- follows:
-
- CONST
- ftSameCircuit = $0001;
- ftSendDisable = $0002;
- ftReceiveDisable = $0004;
- ftTextOnly = $0008;
-
- TYPE
- FTAttributes = INTEGER
-
- ftSameCircuit indicates whether the file transfer tool creates its
- own data connection or expects the application to provide the
- connection. If this bit is set, the file transfer tool uses the data
- connection provided by the application. This bit is set by the file
- transfer tool.
- ftSendDisable indicates that the file transfer tool does not allow
- users to send files. Some tools that support sending files turn this bit
- on when they are in a mode that does not allow users to initiate sending
- files. When this bit is on, your application should dim any menu items
- that allow users to send files.
- ftReceiveDisable indicates that the file transfer tool does not
- allow users to receive files. Some tools that support receiving files
- turn this bit on when they are in a mode that does not allow users to
- initiate receiving files. When this bit is on, your application should
- dim any menu items that allow users to receive files.
- ftTextOnly indicates that the file transfer tool sends and receives
- only text files (files of type TEXT); the tool does not handle resource
- forks. The file transfer tool sets this bit.
- The other bits of this field are reserved by Apple Computer, Inc.
-
-
- æKY InitFT
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$201 (or #513)
- æDT InitFT: FTErr;
- æC -----
- Initializing the File Transfer Manager
-
- Function InitFT: FTErr;
-
- Description: InitFT initializes the File Transfer Manager. Your
- application must call this routine after calling the
- standard Macintosh Toolbox initialization routines.
-
- Warning: Your application must initialize the
- Communications Resource Manager (by calling InitCRM) and
- then the Communications Toolbox Utilities (by calling
- InitCTBUtilities), regardless of whether it uses any of
- their calls, before it initializes the File Transfer
- Manager.
-
- InitFT returns an operating system error code if
- appropriate. Your application must check for the
- presence of the Communications Toolbox before calling
- this function. Sample code under “Determining Whether
- the Managers are Installed” in Appendix C shows you how
- your application can make this check.
-
- Result Codes ftGenericError, ftNoErr, ftNoTools
-
-
- æKY FTGetProcID
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$207 (or #519)
- æDT FTGetProcID(name: Str255): INTEGER;
- æC -----
- Getting current procID information
-
- Function FTGetProcID(name: Str255): INTEGER;
-
- Description: Your application should call FTGetProcID just before
- creating a new file transfer record, to find out the
- procID of a tool.
-
- name specifies a file transfer tool. If a file transfer
- tool is available with the specified name, its procID is
- returned. If name refers to a nonexistent file transfer
- tool, FTGetProcID returns –1.
-
-
- æKY FTNew
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$208 (or #520)
- æDT FTNew(procID: INTEGER; flags: FTFlags; sendProc: ProcPtr; recvProc: ProcPtr; readProc: ProcPtr; writeProc: ProcPtr; environsProc: ProcPtr; owner: WindowPtr; refCon: LONGINT; userData: LONGINT): FTHandle;
- æC -----
- Creating a file transfer record
-
- Function FTNew(procID: INTEGER; flags: FTFlags; sendProc:
- ProcPtr; recvProc: ProcPtr; readProc: ProcPtr;
- writeProc: ProcPtr; environsProc: ProcPtr; owner:
- WindowPtr; refCon: LONGINT; userData: LONGINT): FTHandle;
-
- Description: Before your application can transfer files, it must
- create a file transfer record. FTNew creates a new file
- transfer record, fills in the fields that it can, based
- upon the parameters that were passed to it, and returns
- a handle to the new record in FTHandle. FTNew
- automatically makes two calls to FTDefault (described
- later in this chapter) to fill in config and oldConfig.
- The File Transfer Manager then loads the file transfer
- tool’s main definition procedure, moves it high in the
- current heap, and locks it. If an error occurs that
- prevents a new file transfer record from being created
- (for example, running out of memory), FTNew passes back
- NIL in FTHandle.
-
- procID specifies the file transfer tool the File
- Transfer Manager will use to transfer data.
-
- flags is a bit field with the following masks:
-
- CONST
- ftIsFTMode = $0001;
- ftNoMenus = $0002;
- ftQuiet = $0004;
- ftSucc = $0080;
-
- TYPE
- FTFlags = LONGINT;
-
- flags represents a request from your application for
- a level of service. Your application can set only two of
- these bits, ftNoMenus and ftQuiet. If your application
- sets ftNoMenus, the file transfer tool will not display
- any custom menus. If your application sets ftQuiet, the
- file transfer tool will not display any windows.
- Applications typically use these bits to hide the file
- transfer tool from the user.
- Apple Computer, Inc. has reserved the bits of flags
- that are not shown in this document. Do not use them, or
- your code may not work in the future.
- ftSucc is a bit that is set by the file transfer
- tool when a file transfer is completed successfully.
- Your application should not set this bit.
- Your application can check to see if ftIsFTMode
- toggles from on to off to find out when the file
- transfer has been completed. Then it can check ftSucc to
- see if the file transfer was completed successfully.
-
- sendProc is a pointer to a routine that the application
- uses to send data.
-
- recvProc is a pointer to a routine that the application
- uses to request data.
-
- readProc is a pointer to a routine in your application
- that reads data from a file. The file transfer tool
- checks this field to see if your application has a
- readProc routine. If it does, the tool lets readProc
- handle reading data. If NIL, the file transfer tool
- performs standard file operations (that is, reading data
- from a disk).
- This function can be used to perform preprocessing
- upon a file being sent, and is discussed later in this
- chapter, in “Routines Your Application Provides.”
-
- writeProc is a pointer to a routine in your application
- that writes data to a file. The file transfer tool
- checks this field to see if your application has a
- writeProc routine. If it does, the tool lets
- writeProc handle writing data. If NIL, the file
- transfer tool performs standard file operations
- (that is, writing to a disk).
- This function can be used to perform post-processing
- upon a file being received, and is discussed later in
- this chapter, in “Routines Your Application Provides.”
-
- environsProc is a pointer to a routine that the file
- transfer tool can call when it wants to get information
- about the connection. See Chapter 3 for more information
- about the CMGetConnEnvirons routine.
-
- owner is a pointer to a window, relative to which the
- file transfer status dialog box is positioned. If this
- field is NIL, the File Transfer Manager will not display
- a file transfer status dialog box.
-
- refCon and userData are fields that your application can
- use.
-
-
- æKY FTDefault
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$210 (or #528)
- æDT FTDefault(VAR theConfig: Ptr; procID: INTEGER; allocate: BOOLEAN);
- æC -----
- Initializing the file transfer record
-
- Procedure FTDefault(VAR theConfig: Ptr; procID: INTEGER; allocate:
- BOOLEAN);
-
- Description: FTDefault fills the specified configuration record with
- the default configuration specified by the file transfer
- tool. FTNew calls this procedure automatically when it
- fills in the config and oldConfig fields in a new file
- transfer record.
-
- If allocate is TRUE, the tool allocates space for
- theConfig in the current heap zone.
-
-
- æKY FTValidate
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$20F (or #527)
- æDT FTValidate(hFT: FTHandle): BOOLEAN;
- æC -----
- Validating the file transfer record
-
- Function FTValidate(hFT: FTHandle): BOOLEAN;
-
- Description: FTValidate performs an internal consistency check on the
- configuration and private data records of the file
- transfer record. FTNew and FTSetConfig call this routine
- after they have created a new file transfer record, to
- make sure that the the record contains values identical
- to those specified by the file transfer tool.
-
- If the validation fails, the File Transfer Manager returns
- TRUE and the file transfer tool fills the configuration
- record with default values by calling FTDefault.
- Your application can call this routine after
- restoring a configuration, to verify that the file
- transfer record contains the correct information, in a
- manner similar to that shown next.
-
- BlockMove(saveConfig,hFT^^.config,
- GetPtrSize(hFT^^.config));
- IF FTValidate(hFT) THEN BEGIN
- { validate failed }
- END
- ELSE BEGIN
- { validate succeeded }
- END
-
-
- æKY FTChoose
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21C (or #540)
- æDT FTChoose(VAR hFt:FTHandle; where: Point; idleProc: ProcPtr): INTEGER;
- æC -----
- Configuring a file transfer tool
-
- Function FTChoose(VAR hFt:FTHandle; where: Point; idleProc:
- ProcPtr): INTEGER;
-
- Description: An application can configure a file transfer tool in one
- of three ways. The easiest and most straightforward way
- is by calling the FTChoose routine. This routine
- presents the user with a dialog box.
- The second way an application can configure a file
- transfer tool is by presenting the user with a custom
- tool-settings dialog box. This method is much more
- difficult and involves calling six routines. The
- routines are described in the next section, “Custom
- Configuration of a File Transfer Tool,” and “The Custom
- Tool-Settings Dialog Box” in Appendix C provides example
- code.
- The third way your application can configure a file
- transfer tool is by using the scripting language
- interface, described under “Interfacing with a Scripting
- Language,” later in this chapter. This method allows
- your application to bypass user interface elements.
-
- where is the point, specified in global coordinates,
- where the upper-left corner of the dialog box should
- appear. It is recommended that your application place
- the dialog box as close as possible to the upper-left
- corner of the screen, because the size of the dialog box
- varies from tool to tool.
-
- idleProc is a procedure with no parameters that the File
- Transfer Manager will automatically call every time
- FTChoose loops through the setup dialog filter procedure.
- Pass NIL if your application has no idleProc.
-
- FTChoose returns one of the following values:
-
- CONST
- chooseDisaster = -2;
- chooseFailed = -1;
- chooseOKMinor = 1;
- chooseOKMajor = 2;
- chooseCancel = 3;
-
- chooseDisaster means that the FTChoose operation
- failed, destroyed the file transfer record, and returned
- NIL in the file transfer handle.
-
- chooseFailed means that the operation FTChoose
- failed and the file transfer record was not changed.
-
- chooseOKMinor means that the user clicked OK in the
- dialog box, but did not change the file transfer tool
- being used.
-
- chooseOKMajor means that the user clicked OK in the
- dialog box and also changed the file transfer tool being
- used. The old file transfer handle is destroyed by the
- File Transfer Manager, by calling FTDispose. The file
- transfer is closed down, all pending read and write
- operations are terminated, and a new file transfer
- handle is returned in hFT.
-
- chooseCancel means that the user clicked Cancel in
- the dialog box.
-
-
- æKY FTSetupPreflight
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$211 (or #529)
- æDT FTSetupPreflight(procID: INTEGER; VAR magicCookie: LONGINT): Handle;
- æC -----
- Setting up the tool-settings dialog box
-
- Function FTSetupPreflight(procID: INTEGER; VAR magicCookie:
- LONGINT): Handle;
-
- Description: FTSetupPreflight returns a handle to a dialog item list
- that your application appends to the tool-settings
- dialog box. The handle comes from the file transfer
- tool. (The calling application uses AppendDITL,
- discussed in Chapter 7.) This handle is not a resource
- handle. Your application is responsible for disposing of
- the handle when done with it.
- The file transfer tool can use FTSetupPreflight to
- allocate a block of private storage, and to store the
- pointer to that block in magicCookie. magicCookie should
- be passed to the other routines that are used to set up
- the tool-settings dialog box.
-
- procID is the ID for the file transfer tool that is
- being configured. Your application should get this value
- by using the FTGetProcID routine, discussed earlier in
- this chapter.
-
- Note: The refcon of the custom tool-settings dialog
- box should point to a data structure (an example of
- which is shown next) in which the first two bytes are
- the tool procID and the next four bytes are magicCookie.
- UserItem routines, for example, may require procID to
- obtain tool resources.
-
- TYPE
- chooseDLOGdata=RECORD
- procID:INTEGER
- magicCookie:LONGINT
- END;
-
-
- æKY FTSetupSetup
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$212 (or #530)
- æDT FTSetupSetup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Setting up tool-settings dialog box items
-
- Procedure FTSetupSetup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie:
- LONGINT);
-
- Description: FTSetupSetup tells the file transfer tool to set up
- controls (such as radio buttons or check boxes) in the
- dialog item list returned by FTSetupPreflight.
-
- procID is the ID for the file transfer tool being
- configured. Your application should use the same value
- for procID as it passed to FTSetupPreflight.
-
- theConfig is a pointer to a configuration record for the
- tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box in which configuration is
- taking place.
-
- magicCookie is a pointer to private storage for the file
- transfer tool.
-
-
- æKY FTSetupFilter
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$213 (or #531)
- æDT FTSetupFilter(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theEvent: EventRecord; VAR theItem: INTEGER; VAR magicCookie: LONGINT): BOOLEAN;
- æC -----
- Filtering tool-settings dialog box events
-
- Function FTSetupFilter(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR theEvent:
- EventRecord; VAR theItem: INTEGER; VAR magicCookie:
- LONGINT): BOOLEAN;
-
- Description: Your application calls FTSetupFilter as a filter
- procedure before it calls the standard modal dialog box
- filter procedure for the tool-settings dialog box. This
- routine allows file transfer tools to filter events in
- the tool-settings dialog box.
-
- procID is the ID for the file transfer tool that is
- being configured. Your application should use the same
- value for procID as it passed to FTSetupPreflight.
-
- theConfig is the pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theEvent is the event record for which filtering is to
- take place.
-
- theItem can return the item clicked in the dialog box.
-
- magicCookie is a pointer to private storage for the file
- transfer tool.
-
- If the event passed in was handled, FTSetupFilter
- returns TRUE. FALSE indicates that your application
- should perform standard dialog box filtering.
-
-
- æKY FTSetupItem
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$214 (or #532)
- æDT FTSetupItem(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER; VAR magicCookie: LONGINT);
- æC -----
- Processing tool-settings dialog box events
-
- Procedure FTSetupItem(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER;
- VAR magicCookie: LONGINT);
-
- Description: FTSetupItem processes events for controls in the custom
- tool-settings dialog box.
-
- procID is the ID for the file transfer tool being
- configured. Your application should use the same value
- for procID as it passed to FTSetupPreflight.
-
- theConfig is a pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- theItem is the item clicked in the dialog box. This
- value can be modified and sent back.
-
- magicCookie is a pointer to private storage for the file
- transfer tool.
-
-
- æKY FTSetupCleanup
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$215 (or #533)
- æDT FTSetupCleanup(procID: INTEGER; theConfig: Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
- æC -----
- Performing clean-up operations
-
- Procedure FTSetupCleanup(procID: INTEGER; theConfig: Ptr; count:
- INTEGER; theDialog: DialogPtr; VAR magicCookie:
- LONGINT);
-
- Description: FTSetupCleanup disposes of any storage allocated in
- FTSetupPreflight and performs other clean-up operations.
-
- procID is the ID for the file transfer tool that is
- being configured. Your application should use the same
- value for procID as it passed to FTSetupPreflight.
-
- theConfig is the pointer to the configuration record for
- the tool being configured.
-
- count is the number of the first item in the dialog item
- list appended to the dialog box.
-
- theDialog is the dialog box performing the configuration.
-
- magicCookie is a pointer to private storage for the file
- transfer tool.
-
-
- æKY FTSetupPostflight
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21E (or #542)
- æDT FTSetupPostflight(procID: INTEGER);
- æC -----
- Closing the tool file
-
- Procedure FTSetupPostflight(procID:INTEGER);
-
- Description: FTSetupPostflight closes the tool file if it is not
- being used by any session.
-
- procID is the ID for the file transfer tool that is
- being configured. Your application should use the same
- value for procID as it passed to FTSetupPreflight.
-
-
- æKY FTGetConfig
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$216 (or #534)
- æDT FTGetConfig(hFT: FTHandle): Ptr;
- æC -----
- Getting the configuration string
-
- Function FTGetConfig(hFT: FTHandle): Ptr;
-
- Description: FTGetConfig gets a configuration string from the file
- transfer tool.
-
- FTGetConfig returns a null-terminated, C-style string
- from the file transfer tool containing tokens that fully
- describe the configuration of the file transfer record.
- For an example, see the description of the next routine.
- If an error occurs, FTGetConfig returns NIL.
-
- It is the responsibility of your application to dispose
- of Ptr.
-
-
- æKY FTSetConfig
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$217 (or #535)
- æDT FTSetConfig(hFT: FTHandle; thePtr: Ptr): INTEGER;
- æC -----
- Setting the configuration string
-
- Function FTSetConfig(hFT: FTHandle; thePtr: Ptr): INTEGER;
-
- Description: FTSetConfig passes a configuration string to the file
- transfer tool.
-
- FTSetConfig passes a null-terminated, C-style string
- (see the example string later in this section) to the
- file transfer tool for parsing. The string is pointed
- to by thePtr and must contain tokens that describe the
- configuration of the file transfer record. The string
- can be any length.
- FTSetConfig ignores items it does not recognize or
- find relevant; such an occurrence causes the file
- transfer tool to stop parsing the string and to return
- the character position where the error occurred. If the
- file transfer tool successfully parses the string, it
- returns ftNoErr. If the file transfer tool does not
- successfully parse the string, it returns one of the
- following values: a number less than –1 to indicate an
- OSErr, –1 to indicate an unknown error, or a positive
- number to indicate the character position where parsing
- was stopped.
- Individual file transfer tools are responsible for
- the parsing operation.
-
- Sample: A null-terminated, C-style configuration string
-
- InterCharDelay 0 InterLineDelay 0 WordWrap False Ending
- CR\0
-
-
- æKY FTStart
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$20B (or #523)
- æDT FTStart(hFT: FTHandle; direction: FTDirection; fileInfo: SFReply): FTErr;
- æC -----
- Starting a file transfer
-
- Function FTStart(hFT: FTHandle; direction:FTDirection;
- fileInfo:SFReply): FTErr;
-
- Description: FTStart opens the file that is going to be involved in
- the file transfer, and initializes tool-private
- variables.
- The value in the owner field in the file transfer
- record controls the appearance of a status dialog box.
- The code that performs the actual sending, receiving,
- reading, and writing of data is the responsibility of
- your application. Your application specifies these
- routines when it creates the file transfer record. For a
- description of the parameters that will be passed to
- these routines, see “Routines Your Application
- Provides,” later in this chapter.
-
- direction describes the direction of the file transfer
- and can be either ftReceiving, ftTransmitting, or
- ftFullDuplex.
- Once the file transfer has started, your application
- needs to call FTExec every time it goes through its main
- event loop. Calling FTExec gives the tool time to send
- and receive a packet of data, among other things.
-
- Result Codes ftGenericError, ftNoErr, ftRejected, ftFailed,
- ftTimeout, ftTooManyRetry, ftNotEnoughDspace,
- ftRemoteCancel, ftWrongFormat, ftUserCancel,
- ftNotSupported.
-
-
- æKY FTExec
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$20A (or #522)
- æDT FTExec(hFT: FTHandle);
- æC -----
- Processing file transfer data
-
- Procedure FTExec(hFT: FTHandle);
-
- Description: FTExec is the soul of the file transfer process because
- it allows the file transfer tool to implement the file
- transfer protocol. FTExec handles the disk input and
- output, either through your application or by performing
- local disk input and output, if specified by your
- application. Every time your application calls FTExec, a
- little piece of data is processed until there is no
- more data.
- When sending files, the file transfer tool reads
- data from your application with a readProc, and sends it
- to the connection with a sendProc. When receiving files,
- the file transfer tool gets data from your application
- with a recvProc, and checks if the data arrived
- correctly. The file transfer tool then writes the data
- with a writeProc.
- The readProc, sendProc, recvProc,and writeProc
- routines are discussed in “Routines Your Application
- Provides” later in this chapter.
- At the end of the file transfer, the file transfer
- tool is responsible for closing the file, releasing any
- memory allocated, and resetting the ftIsFTMode bit in
- the file transfer record.
-
-
- æKY FTAbort
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$20D (or #525)
- æDT FTAbort(hFT: FTHandle): FTErr;
- æC -----
- Stopping a file transfer
-
- Function FTAbort(hFT: FTHandle): FTErr;
-
- Description: FTAbort aborts a file transfer in progress. The file
- transfer tool sends the appropriate canceling characters
- to the remote computer, and stops the file transfer.
-
- Result Codes ftGeneric, ftNoErr, ftRejected, ftFailed, ftNotSupported.
-
-
- æKY FTDispose
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$209 (or #521)
- æDT FTDispose(hFT: FTHandle);
- æC -----
- Disposing of a file transfer record
-
- Procedure FTDispose(hFT: FTHandle);
-
- Description: FTDispose disposes of the file transfer record and all
- associated data structures. The file transfer tool stops
- any file transfer in progress (as specified by the file
- transfer record).
-
-
- æKY FTActivate
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$220 (or #544)
- æDT FTActivate(hFT: FTHandle; activate: BOOLEAN);
- æC -----
- Activate events
-
- Procedure FTActivate(hFT: FTHandle; activate: BOOLEAN);
-
- Description: FTActivate processes an activate or deactivate event
- (for instance, installing or removing a custom tool
- menu) for a window associated with the file transfer.
-
- If activate is TRUE, the file transfer tool processes an
- activate event. Otherwise, it processes a deactivate
- event.
-
-
- æKY FTResume
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$20E (or #526)
- æDT FTResume(hFT: FTHandle; resume: BOOLEAN);
- æC -----
- Resume events
-
- Procedure FTResume(hFT: FTHandle; resume: BOOLEAN);
-
- Description: FTResume is called when your application receives a
- suspend or a resume event. The file transfer tool may
- decide to change timeout values or other parameters,
- depending on whether the application is running in the
- foreground.
-
- If resume is TRUE, the file transfer tool processes a
- resume event. Otherwise, it processes a suspend event.
-
-
- æKY FTMenu
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21F (or #543)
- æDT FTMenu(hFT: FTHandle; menuID: INTEGER; item: INTEGER): BOOLEAN;
- æC -----
- Menu events
-
- Function FTMenu(hFT: FTHandle; menuID: INTEGER; item: INTEGER):
- BOOLEAN;
-
- Description: Your application must call FTMenu when the user chooses
- an item from a menu installed by the file transfer tool.
-
- FTMenu returns FALSE if the file transfer tool did not
- handle the menu event.
-
- FTMenu returns TRUE if the file transfer tool did handle
- the menu event.
-
-
- æKY FTEvent
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21D (or #541)
- æDT FTEvent(hFT: FTHandle; theEvent: EventRecord);
- æC -----
- Other events
-
- Procedure FTEvent(hFT: FTHandle; theEvent: EventRecord);
-
- Description: When your application receives an event, it should check
- if the refcon of the window is a tool’s hFT. Such an
- event occurs, for example, when the user clicks a button
- in a dialog box displayed by the file transfer tool. If
- it does belong to a file transfer tool’s window, your
- application can call FTEvent.
-
- A window (or dialog box) created by a file transfer tool
- has a file transfer record handle stored in the refCon
- field for windowRecord.
-
-
- æKY FTIntlToEnglish
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$218 (or #536)
- æDT FTIntlToEnglish(hFT: FTHandle; inputPtr: Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
- æC -----
- Translating into English
-
- Function FTIntlToEnglish(hFT: FTHandle; inputPtr: Ptr; VAR
- outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: FTIntlToEnglish converts a configuration string, which
- is pointed to by inputPtr, to an American English
- configuration string pointed to by outputPtr.
-
- This function returns an operating system error code if
- any internal errors occur.
- The file transfer tool allocates space for outputPtr.
- Your application is responsible for disposing of the
- pointer with DisposPtr when done with it.
- language specifies the language from which the
- string is to be converted. Valid values for this field
- are shown in the description of the Script Manager in
- Inside Macintosh, Volume V. If the language specified
- is not supported, this routine returns noErr, but
- outputPtr is NIL.
-
-
- æKY FTEnglishToIntl
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$219 (or #537)
- æDT FTEnglishToIntl(hFT: FTHandle; inputPtr: Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
- æC -----
- Translating from English
-
- Function FTEnglishToIntl(hFT: FTHandle; inputPtr: Ptr; VAR
- outputPtr: Ptr; language: INTEGER): OSErr;
-
- Description: FTEnglishToIntl converts an American English
- configuration string, which is pointed to by inputPtr,
- to a configuration string pointed to by outputPtr.
-
- This function returns an operating system error code if
- any internal errors occur.
- The file transfer tool allocates space for
- outputPtr; your application is responsible for disposing
- of the pointer with DisposPtr when done with it.
- language specifies the language to which the string
- is to be converted. Valid values for this field are
- shown in the description of the Script Manager in Inside
- Macintosh, Volume V. If the language specified is not
- supported, noErr is still returned, but outputPtr is NIL.
-
-
- æKY FTGetToolName
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$206 (or #518)
- æDT FTGetToolName(procID: INTEGER; VAR name: Str255);
- æC -----
- Getting the name of a tool
-
- Procedure FTGetToolName(procID: INTEGER; VAR name: Str255);
-
- Description: FTGetToolName returns in name the name of the tool
- specified by procID.
-
- If procID references a file transfer tool that does not
- exist, the File Transfer Manager sets name to an empty
- string.
-
- æKY FTSetRefCon
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$202 (or #514)
- æDT FTSetRefCon(hFT: FTHandle; refCon: LONGINT);
- æC -----
- Setting the file transfer record's reference constant
-
- Procedure FTSetRefCon(hFT: FTHandle; refCon: LONGINT);
-
- Description: FTSetRefCon sets the file transfer record refCon to the
- given value. It is very important that your application
- use this routine to change the value of the reference
- constant, instead of changing it directly.
-
-
- æKY FTGetRefCon
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$203 (or #515)
- æDT FTGetRefCon(hFT: FTHandle): LONGINT;
- æC -----
- Getting the file transfer record reference constant
-
- Function FTGetRefCon(hFT: FTHandle): LONGINT;
-
- Description: FTGetRefCon returns the file transfer record reference
- constant.
-
-
- æKY FTSetUserData
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$204 (or #516)
- æDT FTSetUserData(hFT: FTHandle; userData: LONGINT);
- æC -----
- Setting the userData field
-
- Procedure FTSetUserData(hFT: FTHandle; userData: LONGINT);
-
- Description: FTSetUserData sets the file transfer record’s userData
- field to the given value. It is very important that your
- application use this routine to change the value of the
- userData field, instead of changing it directly.
-
-
- æKY FTGetUserData
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$205 (or #517)
- æDT FTGetUserData(hFT: FTHandle): LONGINT;
- æC -----
- Getting the userData field
-
- Function FTGetUserData(hFT: FTHandle) : LONGINT;
-
- Description: FTGetUserData returns the file transfer record’s
- userData field.
-
-
- æKY FTGetVersion
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21A (or #538)
- æDT FTGetVersion(hFT: FTHandle): Handle;
- æC -----
- Getting 'vers' resource information
-
- Function FTGetVersion(hFT: FTHandle): Handle;
-
- Description: FTGetVersion returns a handle to a relocatable block
- that contains the information in the file transfer
- tool’s 'vers' resource with ID=1. Your application is
- responsible for disposing of the handle when done with
- it.
-
- Note: The handle returned is not a resource handle.
-
-
- æKY FTGetFTVersion
- æFa FileTransfers.a
- æFc FileTransfers.h
- æFp FileTransfers.p
- æMM
- æTN $A08B A0^.w=$21B (or #539)
- æDT FTGetFTVersion: INTEGER;
- æC -----
- Getting the File Transfer Manager version number
-
- Function FTGetFTVersion: INTEGER;
-
- Description: FTGetFTVersion returns the version number of the File
- Transfer Manager.
-
- The version number of the File Transfer Manager
- described in this document is:
-
- CONST
- curFTVersion = 1;
-
-
- æKY MyReadProc
- æDT MyReadProc(VAR count: LONGINT; bufPtr: Ptr; refCon: LONGINT; fileMsg: INTEGER): OSErr;
- æC -----
- Reading data
-
- Function MyReadProc(VAR count : LONGINT; bufPtr : Ptr; refCon :
- LONGINT; fileMsg : INTEGER) : OSErr;
-
- Description: MyReadProc is a routine in your application that the
- file transfer tool calls to read data from a file. After
- MyReadProc reads the data, the file transfer tool
- typically sends the data by calling the MySendProc
- routine, which is described next. MyReadProc is also
- responsible for opening and closing the file from which
- the outgoing data is read.
-
- MyReadProc must return an error code when appropriate.
-
- count is a bit field with the following bit masks
- defined:
-
- CONST
- ftOpenDataFork = $00000001;
- ftOpenRsrcFork = $00000002;
-
- refCon is the reference constant of the file transfer
- record.
-
- fileMsg specifies which service the file transfer tool
- requires MyReadProc to provide.
-
- CONST
- ftReadOpenFile = 0;
- ftReadDataFork = 1;
- ftReadRsrcFork = 2;
- ftReadAbort = 3;
- ftReadComplete = 4;
-
- ftReadOpenFile
- ftReadOpenFile indicates that the file transfer tool
- requires MyReadProc to open a file. The bits set in
- count specify whether MyReadProc should open the
- resource fork, data fork, or both. bufPtr points to a
- parameter block that specifies the file MyReadProc
- should open. The parameter block the file transfer tool
- passes to MyReadProc is the same as that returned from
- calling PBGetFInfo.
-
- ftReadDataFork and ftReadRsrcFork
- These messages indicate that the file transfer tool
- requires MyReadProc to read data from an open file,
- which it had previously opened in response to
- ftReadOpenFile. count specifies the number of bytes
- MyReadProc should read. When finished reading,
- MyReadProc puts the actual number of bytes read into
- count. bufPtr points to the buffer into which
- MyReadProc should read data.
-
- ftReadAbort and ftReadComplete
- These messages indicate that MyReadProc should close the
- file it had opened in response to ftReadOpenFile.
-
-
- æKY MySendProc
- æC -----
- Sending data
-
- Function MySendProc(thePtr: Ptr; theSize: LONGINT; refCon:
- LONGINT; channel: CMChannel; flags: CMFlags):LONGINT;
-
- Description: MySendProc is a routine in your application that the
- file transfer tool calls to send data that is in a
- buffer.
-
- MySendProc must return the actual number of bytes it
- sent.
-
- thePtr is a pointer to a block of data in memory that is
- to be sent.
-
- theSize is the length of that block.
-
- refCon is the reference constant of the file transfer
- record.
-
- channel specifies the channel that the file transfer
- tool can use. Your application should specify one of the
- following values for channel: CMData, CMCntl, or CMAttn.
-
- flags is described in Chapter 3 under the description of
- CMWrite.
-
- Sample send routine
-
- FUNCTION MySendProc(thePtr: Ptr;theSize: LONGINT;refcon: LONGINT;
- channel: CMChannel;flags: INTEGER) : LONGINT;
- VAR
- theErr : CMErr; { Errors on a write }
-
- BEGIN
- MySendProc:= 0; { Assume the worst }
-
- IF gConn <> NIL THEN BEGIN { Send the data }
- theErr := CMWrite(gConn,thePtr,theSize,channel,FALSE,
- NIL, 0, flags);
- IF (theErr = noErr) THEN
- MySendProc:= theSize { if ok, we sent all }
- ELSE
- ; { Handle errors }
- END; { Good Connection }
- END; { MySendProc }
-
-
- æKY MyRecvProc
- æC -----
- Receiving data
-
- Function MyRecvProc (thePtr: Ptr; theSize: LONGINT; refCon:
- LONGINT; channel: CMChannel; VAR flags: CMFlags):
- LONGINT;
-
- Description: MyRecvProc is a routine in your application that the
- file transfer tool uses to receive data into a buffer
- from the connection.
-
- MyRecvProc must return the actual number of bytes it
- received.
-
- thePtr is a pointer to a block of data in memory where
- the incoming data is to be placed.
-
- theSize is the length of that data.
-
- refCon is the reference constant of the file transfer
- record.
-
- channel specifies the data channel that the file
- transfer tool can use. Your application should specify
- one of the following values for channel: CMData, CMCntl,
- or CMAttn.
-
- flags is described in Chapter 3 under the description of
- CMRead.
-
- Sample receive routine
-
- FUNCTION MyRecvProc (thePtr: Ptr;theSize: LONGINT;refcon: LONGINT;
- channel: CMChannel;VAR flags: INTEGER): LONGINT;
- VAR
- theErr : CMErr; { Any errors }
-
- BEGIN
- MyRecvProc := 0; { Assume the worst }
-
- IF gConn <> NIL THEN BEGIN
- { Read all the data }
- theErr := CMRead(gConn,thePtr,theSize,channel,FALSE,NIL,0,
- flags);
- IF (theErr <> noErr) THEN
- MyRecvProc := theSize { if ok, we got all }
- ELSE
- ; { Handle errors }
- END; { Good Connection }
- END; { MyRecvProc }
-
-
- æKY MyWriteProc
- æC -----
- Writing data
-
- Function MyWriteProc(VAR count: LONGINT; bufPtr: Ptr; refCon:
- LONGINT; fileMsg: INTEGER): OSErr;
-
- Description: MyWriteProc is a routine in your application that the
- file transfer tool calls to write data to a file.
- MyWriteProc is also responsible for opening and closing
- the file to which the outgoing data is written.
-
- MyWriteProc must return an error code when appropriate.
-
- count is a bit field with the following bit masks
- defined:
-
- CONST
- ftOpenDataFork = 1;
- ftOpenRsrcFork = 2;
-
- refCon is the reference constant of the file transfer
- record.
-
- fileMsg specifies which service the file transfer tool
- requires MyWriteProc to provide.
-
- CONST
- ftWriteOpenFile = 0;
- ftWriteDataFork = 1;
- ftWriteRsrcFork = 2;
- ftWriteAbort = 3;
- ftWriteComplete = 4;
- ftWriteFileInfo = 5;
-
- ftWriteOpenFile
- ftWriteOpenFile indicates that the file transfer
- tool requires MyWriteProc to open a file. The bits
- set in count specify whether MyWriteProc should open
- the resource fork, data fork, or both. bufPtr points
- to a parameter block that specifies the file
- MyWriteProc should open. The parameter block the
- file transfer tool passes to MyWriteProc is the same
- as that returned from calling PBGetFInfo.
-
- Note that MyWriteProc creates the file specified by
- the parameter block. If the file transfer protocol
- in use does not specify the filename for the
- incoming file, MyWriteProc must generate one. Your
- application must handle filename conflicts and
- AppleShare file server permission problems if they
- arise.
-
- ftWriteDataFork and ftWriteRsrcFork
- These messages indicate that the file transfer tool
- requires MyWriteProc to open a file. count specifies
- the number of bytes to write. When finished writing
- data, MyWriteProc should set count to the actual
- number of bytes written. bufPtr points to the buffer
- into which MyWriteProc should write data.
-
- ftWriteAbort
- ftWriteAbort indicates that MyWriteProc should close the
- open file and delete it.
-
- ftWriteComplete
- ftWriteComplete indicates that MyWriteProc should close
- the open file.
-
- ftWriteFileInfo
- ftWriteFileInfo indicates that the file transfer tool
- requires MyWriteProc to change file information. bufPtr
- points to a parameter block that MyWriteProc can pass to
- the File Manager routine PBSetFInfo.
-
-
- æKY MyEnvironsProc
- æC -----
- Getting the connection environment
-
- Function MyEnvironsProc(refCon: LONGINT; VAR theEnvirons:
- ConnEnvironRec): CMErr;
-
- Description: Sometimes the file transfer tool needs to know about the
- type of connection on which to transfer files. For
- example, some file transfer protocols require an 8-bit
- data channel. To get this information, the file transfer
- tool calls a routine in your application, MyEnvironsProc.
-
- refCon is the reference constant of the file transfer
- record.
-
- theEnvirons is a data structure containing the
- connection-environment record. Your application can
- either construct theEnvirons or use the Connection
- Manager routine CMGetConnEnvirons. For more information
- about theEnvirons, see “CMGetConnEnvirons Getting the
- Connection Environment” in Chapter 3.
- The example that follows shows how MyEnvironsProc
- can point to a Connection Manager routine to retrieve
- information about the connection environment.
-
- Result Codes cmGenericError, cmNoErr, cmNotSupported, envVersTooBig.
-
-
- Sample connection-environment routine
- FUNCTION MyEnvironsProc(refCon: LONGINT; VAR theEnvirons:
- ConnEnvironRec): OSErr;
- BEGIN
- MyEnvironsProc:= envNotPresent; { pessimism }
-
- { Get the connection info }
- IF gConn <> NIL THEN { Tool sets the version }
- MyEnvironsProc:= CMGetConnEnvirons(gConn,theEnvirons);
- END; { MyEnvironsProc}
-
-
- æKY Communication Toolbox
- æC -----
- Connection Manager
- File Transfer Manager
- Terminal Manager
- Communications Resource Manager
-
- æKY CTB
- æC -----
- Connection Manager
- File Transfer Manager
- Terminal Manager
- Communications Resource Manager
-
-
-
- æKY Communications Resource Manager
- æC -----
- CRMGet1IndResource CRMGetResource
- CRMGet1NamedResource CRMInstall
- CRMGet1Resource CRMLocalToRealID
- CRMGetCRMVersion CRMRealToLocalID
- CRMGetHeader CRMReleaseResource
- CRMGetIndex CRMRemove
- CRMGetIndResource CRMSearch
- CRMGetIndToolName InitCRM
- CRMGetNamedResource
-
- CRMRecord
-
-
- æKY CommResources
- æC -----
- CRMGet1IndResource CRMGetResource
- CRMGet1NamedResource CRMInstall
- CRMGet1Resource CRMLocalToRealID
- CRMGetCRMVersion CRMRealToLocalID
- CRMGetHeader CRMReleaseResource
- CRMGetIndex CRMRemove
- CRMGetIndResource CRMSearch
- CRMGetIndToolName InitCRM
- CRMGetNamedResource
-
- CRMRecord
-
-
- æKY CRMgr
- æC -----
- CRMGet1IndResource CRMGetResource
- CRMGet1NamedResource CRMInstall
- CRMGet1Resource CRMLocalToRealID
- CRMGetCRMVersion CRMRealToLocalID
- CRMGetHeader CRMReleaseResource
- CRMGetIndex CRMRemove
- CRMGetIndResource CRMSearch
- CRMGetIndToolName InitCRM
- CRMGetNamedResource
-
- CRMRecord
-
-
- æKY CRMRecord
- æC -----
- TYPE
- CRMRecPtr = ^CRMRec;
- CRMRec = RECORD
- qLink : QElemPtr;
- qType : INTEGER;
- crmVersion : INTEGER;
- crmPrivate : LONGINT;
- crmReserved : INTEGER;
- crmDeviceType : LONGINT;
- crmDeviceID : LONGINT;
- crmAttributes : LONGINT;
- crmStatus : LONGINT;
- crmRefCon : LONGINT;
- END;
-
-
- qLink
- qLink points to the next CRMRec in the Communications Resource Manager’s
- queue of communications resource records.
-
-
- qType
- qType is a constant that your code must fill with the constant crmType.
-
-
- crmVersion
- crmVersion is the version number of the CRMRec data structure. At this
- time there is only one version, so the Communications Resource Manager
- fills this with the constant crmRecVersion.
-
-
- crmPrivate and crmReserved
- crmPrivate and crmReserved are private to the Communications Resource
- Manager; your code must not use them.
-
-
- crmDeviceType
- crmDeviceType is the type of device. For example, a serial port has a
- crmDeviceType of crmSerialDevice.
-
-
- crmDeviceID
- crmDeviceID is an identifier that your code can use to distinguish
- between multiple devices of the same device type. The Communications
- Resource Manager fills in this field when your code calls the
- CRMInstall routine.
-
-
- crmAttributes
- crmAttributes specifies the attributes of a specific device type. This
- field can hold either a pointer to the data or the actual data that
- describes the device. A sample crmAttributes data structure appears later
- in this chapter in the section “Registering a Device.”
-
-
- crmStatus
- crmStatus specifies the status of a device. Your code can use this field
- for device arbitration purposes.
-
-
- crmRefCon
- crmRefCon is not used in this release of the Communications Resource
- Manager.
-
-
- æKY InitCRM
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$501 (or #1281)
- æDT InitCRM: CRMErr;
- æC -----
- Initializing the Communications Resource Manager
-
- Function InitCRM:CRMErr;
-
- Description: InitCRM initializes the Communications Resource Manager.
-
- Warning: Your code must call this routine after
- calling the standard Macintosh Toolbox initialization
- routines and before calling any of the other
- Communications Toolbox manager initialization routines.
-
- InitCRM returns an operating system error code if
- appropriate.
- Your code must check for the presence of the
- Communications Toolbox before calling this function.
- Sample code under “Determining Whether the Managers Are
- Installed” in Appendix C shows you how your application
- can make this check.
-
- Result Codes crmGenericError, crmNoErr.
-
-
- æKY CRMInstall
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$503 (or #1283)
- æDT CRMInstall(crmReqPtr: QElemPtr);
- æC -----
- Installing devices
-
- Procedure CRMInstall(crmReqPtr: QElemPtr);
-
- Description: CRMInstall installs a device into the Communications
- Resource Manager’s queue. Devices in the Communications
- Resource Manager queue typically have their CRMRec
- records allocated in the system heap. If your code
- installs a CRMRec at startup time, be sure that your code
- increases the size of the system heap appropriately.
- For more information on how to register a device with
- the Communications Resource Manager, read “Registering a
- Device,” later in this chapter.
-
- CRMInstall installs the communications resource record
- crmReqPtr into the Communications Resource Manager queue.
-
- Warning: A CRMRec allocated in the application heap
- needs to be removed before the application heap is
- reinitialized; otherwise, the Communications Resource
- Manager queue may be damaged.
-
-
- æKY CRMSearch
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$505 (or #1285)
- æDT CRMSearch(crmReqPtr: QElemPtr): QElemPtr;
- æC -----
- Searching for devices
-
- Function CRMSearch(crmReqPtr: QElemPtr): QElemPtr;
-
- Description: Your code can use CRMSearch to order the Communications
- Resource Manager queue, or to add new elements to the end
- of the queue.
-
- crmReqPtr specifies communications resource record search
- criteria.
- CRMSearch searches for a device in the Communications
- Resource Manager queue that has two characteristics: the
- same deviceType, and a deviceID greater than the deviceID
- in the record specified by crmReqPtr. CRMSearch returns a
- pointer to the first record that it finds that meets
- these two conditions. Or, if no records meet the search
- criteria, it returns NIL.
- When searching for the first element in the queue,
- your code must pass 0 in deviceID.
-
-
- æKY CRMRemove
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$504 (or #1284)
- æDT CRMRemove(crmReqPtr: QElemPtr): OSErr;
- æC -----
- Removing devices
-
- Function CRMRemove(crmReqPtr: QElemPtr): OSErr;
-
- Description: CRMRemove removes a device from the Communications
- Resource Manager queue.
-
- crmReqPtr specifies the device to be removed.
-
-
- æKY CRMGetCRMVersion
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$506 (or #1286)
- æDT CRMGetCRMVersion: INTEGER;
- æC -----
- Getting the version number
-
- Function CRMGetCRMVersion: INTEGER;
-
- Description: CRMGetCRMVersion returns the version number of the
- Communications Resource Manager.
-
- The Communications Resource Manager version described in
- this document is:
-
- CONST
- curCRMVersion = 1;
-
-
- æKY CRMGetHeader
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$502 (or #1282)
- æDT CRMGetHeader: QHdrPtr;
- æC -----
- Getting to the head of the queue
-
- Function CRMGetHeader: QHdrPtr;
-
- CRMGetHeader returns a pointer to the head of the Communications Resource
- Manager queue.
-
-
- æKY CRMGetResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$507 (or #1287)
- æDT CRMGetResource(theType: ResType; theID: INTEGER): Handle;
- æC -----
- Loading resources
-
- Function CRMGetResource(theType: ResType; theID: INTEGER): Handle;
-
- CRMGetResource and CRMGet1Resource call the Resource
- Manager routines GetResource and Get1Resource,
- respectively, and return a handle to the specified
- communications resource. The Communications Resource
- Manager then adds the handle to the list of resources
- that it is managing, and increases by one the use count,
- which indicates how many pieces of code are using a
- resource.
-
-
- æKY CRMGet1Resource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$508 (or #1288)
- æDT CRMGet1Resource(theType: ResType; theID: INTEGER): Handle;
- æC -----
- Loading resources
-
- Function CRMGet1Resource(theType: ResType; theID: INTEGER): Handle;
-
- CRMGetResource and CRMGet1Resource call the Resource
- Manager routines GetResource and Get1Resource,
- respectively, and return a handle to the specified
- communications resource. The Communications Resource
- Manager then adds the handle to the list of resources
- that it is managing, and increases by one the use count,
- which indicates how many pieces of code are using a
- resource.
-
-
- æKY CRMGetIndResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$509 (or #1289)
- æDT CRMGetIndResource(theType: ResType; index: INTEGER): Handle;
- æC -----
- Loading indexed resources
-
- Function CRMGetIndResource(theType: ResType; index: INTEGER): Handle;
-
- CRMGetIndResource and CRMGet1IndResource call the
- Resource Manager routines GetIndResource and
- Get1IndResource, respectively, and return a handle to the
- specified communications resource. The Communications
- Resource Manager then adds the handle to the list of
- resources that it is managing, and increases by one the
- use count, which indicates how many pieces of code are
- using a resource.
-
-
- æKY CRMGet1IndResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50A (or #1290)
- æDT CRMGet1IndResource(theType: ResType; index: INTEGER): Handle;
- æC -----
- Loading indexed resources
-
- Function CRMGet1IndResource(theType: ResType; index: INTEGER): Handle;
-
- CRMGetIndResource and CRMGet1IndResource call the
- Resource Manager routines GetIndResource and
- Get1IndResource, respectively, and return a handle to the
- specified communications resource. The Communications
- Resource Manager then adds the handle to the list of
- resources that it is managing, and increases by one the
- use count, which indicates how many pieces of code are
- using a resource.
-
-
- æKY CRMGetNamedResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50B (or #1291)
- æDT CRMGetNamedResource(theType: ResType; name: Str255): Handle;
- æC -----
- Loading named resources
-
- Function CRMGetNamedResource(theType: ResType; name: Str255): Handle;
-
- CRMGetNamedResource and CRMGet1NamedResource call
- GetNamedResource and Get1NamedResource, respectively, and
- return a handle to the specified communications resource.
- The Communications Resource Manager then adds the handle
- to the list of resources that it is managing, and
- increases by one the use count, which indicates how many
- pieces of code are using a resource.
-
-
- æKY CRMGet1NamedResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50C (or #1292)
- æDT CRMGet1NamedResource(theType: ResType; name: Str255): Handle;
- æC -----
- Loading named resources
-
- Function CRMGet1NamedResource(theType: ResType; name: Str255): Handle;
-
- CRMGetNamedResource and CRMGet1NamedResource call
- GetNamedResource and Get1NamedResource, respectively, and
- return a handle to the specified communications resource.
- The Communications Resource Manager then adds the handle
- to the list of resources that it is managing, and
- increases by one the use count, which indicates how many
- pieces of code are using a resource.
-
-
- æKY CRMGetIndex
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50E (or #1294)
- æDT CRMGetIndex(theHandle: Handle): LONGINT;
- æC -----
- Getting a usage index for a resource
-
- Function CRMGetIndex(theHandle: Handle): LONGINT;
-
- CRMGetIndex returns a use count which indicates how many
- pieces of code are simultaneously using a resource with
- the specified handle. CRMGetIndex returns 0 if it does
- not find theHandle in the list of resources the
- Communications Resource Manager is managing.
-
-
-
- æKY CRMReleaseResource
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50D (or #1293)
- æDT CRMReleaseResource(theHandle: Handle);
- æC -----
- Releasing resources
-
- Procedure CRMReleaseResource(theHandle: Handle);
-
- CRMReleaseResource decreases by 1 the value that
- indicates how many pieces of code have requested a
- resource. If the use count reaches 0, the resource
- specified by theHandle is released with a call to the
- Resource Manager routine ReleaseResource.
-
- Warning: Your code must release communications
- resources by calling CRMReleaseResource. If your code
- tries to release the resources using the Resource Manager
- routine ReleaseResource, the results are unpredictable.
-
-
- æKY CRMLocalToRealID
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$50F (or #1295)
- æDT CRMLocalToRealID(bundleType: ResType; toolID: INTEGER; theKind: ResType; localID: INTEGER): INTEGER;
- æC -----
- Mapping to Real ID
-
- Function CRMLocalToRealID(bundleType: ResType; toolID: INTEGER;
- theKind: ResType; localID: INTEGER): INTEGER;
-
- Description: CRMLocalToRealID maps a local resource ID to a physical
- resource.
-
- This routine returns the (physical/local) resource ID if
- an appropriate entry exists in the tool bundle resource.
- If no entry is found, –1 is returned.
-
- bundleType specifies the type of tool for which the
- mapping is to take place: ClassCM (for connection tools),
- ClassTM (for terminal tools), or ClassFT (for file
- transfer tools).
-
- toolID specifies the bundle resource for the tool.
-
-
- æKY CRMRealToLocalID
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$510 (or #1296)
- æDT CRMRealToLocalID(bundleType: ResType; toolID: INTEGER; theKind: ResType; realID: INTEGER): INTEGER;
- æC -----
- Mapping to Local ID
-
- Function CRMRealToLocalID(bundleType: ResType; toolID: INTEGER;
- theKind: ResType; realID: INTEGER): INTEGER;
-
- Description: CRMRealToLocalID maps a physical resource ID to a local
- resource ID.
-
- This routine returns the (physical/local) resource ID if
- an appropriate entry exists in the tool bundle resource.
- If no entry is found, –1 is returned.
-
- bundleType specifies the type of tool for which the
- mapping is to take place: ClassCM (for connection tools),
- ClassTM (for terminal tools), or ClassFT (for file
- transfer tools).
-
- Here is the format for a connection tool bundle resource
- (in Rez format). The same resource type declaration holds
- for terminal tools and file transfer tools.
-
- type 'cbnd' { /* or tbnd, or fbnd */
- integer = $$CountOf(TypeArray) - 1;
- array TypeArray {
- literal longint; /* Type */
- integer = $$CountOf(IDArray) - 1;
- wide array IDArray {
- integer; /* Local ID */
- integer; /* Actual ID */
- };
- };
- };
-
-
- æKY CRMGetIndToolName
- æFa CommResources.a
- æFc CommResources.h
- æFp CommResources.p
- æMM
- æTN $A08B A0^.w=$511 (or #1297)
- æDT CRMGetIndToolName(bundleType: OSType; index: INTEGER; VAR toolName: Str255): OSErr;
- æC -----
- Getting the name of a tool
-
- Function CRMGetIndToolName(bundleType: OSType; index: INTEGER;
- VAR toolName: Str255): OSErr;
-
- Description: CRMGetIndToolName returns the name of a tool in toolName.
-
- The appropriate values for bundleType are as follows:
-
- CONST
- ClassCM = 'cbnd';
- ClassFT = 'fbnd';
- ClassTM = 'tbnd';
-
- index specifies which occurrence of a particular type of
- tool to return. For example, if index is 2, the
- Communications Resource Manager returns the name of the
- second tool of a particular type in toolName. If the
- Communications Resource Manager cannot find a tool that
- matches the specified parameters, an empty string is
- returned in toolName.
-